Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace Gedmo\Timestampable\Mapping\Event\Adapter;
use Gedmo\Mapping\Event\Adapter\ODM as BaseAdapterODM;
use Gedmo\Timestampable\Mapping\Event\TimestampableAdapter;
/**
* Doctrine event adapter for ODM adapted
* for Timestampable behavior
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
final class ODM extends BaseAdapterODM implements TimestampableAdapter
{
/**
* {@inheritDoc}
*/
public function getDateValue($meta, $field)
{
$mapping = $meta->getFieldMapping($field);
if (isset($mapping['type']) && $mapping['type'] === 'timestamp') {
return time();
}
if (isset($mapping['type']) && $mapping['type'] == 'zenddate') {
return new \Zend_Date();
}
if (isset($mapping['type']) && in_array($mapping['type'], array('date_immutable', 'time_immutable', 'datetime_immutable', 'datetimetz_immutable'), true)) {
return new \DateTimeImmutable();
}
return \DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))
->setTimeZone(new \DateTimeZone(date_default_timezone_get()));
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Gedmo\Timestampable\Mapping\Event\Adapter;
use Gedmo\Mapping\Event\Adapter\ORM as BaseAdapterORM;
use Gedmo\Timestampable\Mapping\Event\TimestampableAdapter;
/**
* Doctrine event adapter for ORM adapted
* for Timestampable behavior
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
final class ORM extends BaseAdapterORM implements TimestampableAdapter
{
/**
* {@inheritDoc}
*/
public function getDateValue($meta, $field)
{
$mapping = $meta->getFieldMapping($field);
if (isset($mapping['type']) && $mapping['type'] === 'integer') {
return time();
}
if (isset($mapping['type']) && $mapping['type'] == 'zenddate') {
return new \Zend_Date();
}
if (isset($mapping['type']) && in_array($mapping['type'], array('date_immutable', 'time_immutable', 'datetime_immutable', 'datetimetz_immutable'), true)) {
return new \DateTimeImmutable();
}
return \DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))
->setTimeZone(new \DateTimeZone(date_default_timezone_get()));
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Gedmo\Timestampable\Mapping\Event;
use Gedmo\Mapping\Event\AdapterInterface;
/**
* Doctrine event adapter interface
* for Timestampable behavior
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
interface TimestampableAdapter extends AdapterInterface
{
/**
* Get the date value
*
* @param object $meta
* @param string $field
*
* @return mixed
*/
public function getDateValue($meta, $field);
}