Last active
December 17, 2015 08:48
-
-
Save rufinus/5582295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$hydra = new DoctrineHydrator($sm->get('Doctrine\ORM\EntityManager', false)); | |
$hydra->addStrategy('date_start', new \cwdCommon\Doctrine\Strategy\DateTime()); | |
$hydra->addStrategy('date_end', new \cwdCommon\Doctrine\Strategy\DateTime()); | |
$this->setHydrator($hydra); | |
$this->setObject(new \Application\Entity\Event()); | |
$this->add( | |
array( | |
'name' => 'date_start', | |
'options' => array( | |
'label' => 'Date' | |
), | |
'attributes' => array( | |
'id' => 'date-from-raw' | |
) | |
) | |
); | |
$this->add( | |
array( | |
'name' => 'date_end', | |
'options' => array( | |
'label' => 'Date' | |
), | |
'attributes' => array( | |
'id' => 'date-to-raw' | |
) | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace cwdCommon\Doctrine\Strategy; | |
use Zend\Stdlib\Hydrator\Strategy\StrategyInterface; | |
class DateTime implements StrategyInterface | |
{ | |
/** | |
* Converts the given value so that it can be extracted by the hydrator. | |
* | |
* @param mixed $value The original value. | |
* @return mixed Returns the value that should be extracted. | |
*/ | |
public function extract($value) | |
{ | |
return 'extract'; | |
} | |
/** | |
* Converts the given value so that it can be hydrated by the hydrator. | |
* | |
* @param mixed $value The original value. | |
* @return mixed Returns the value that should be hydrated. | |
*/ | |
public function hydrate($value) | |
{ | |
return 'hydrate'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment