Created
November 28, 2013 17:04
-
-
Save mmenozzi/7695055 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* @author Manuele Menozzi <[email protected]> | |
*/ | |
namespace Erica\EricaBundle\EventListener; | |
use Doctrine\Common\EventArgs; | |
use Gedmo\Timestampable\TimestampableListener; | |
class TimestampableFieldsSubscriber extends TimestampableListener | |
{ | |
public function loadClassMetadata(EventArgs $eventArgs) | |
{ | |
$metadata = $eventArgs->getClassMetadata(); | |
if (strstr($metadata->getName(), 'Erica') === false) { | |
return; | |
} | |
if (count($metadata->parentClasses)) { | |
return; | |
} | |
$metadata->mapField( | |
array( | |
'fieldName' => 'createdAt', | |
'columnName' => 'created_at', | |
'type' => 'datetime' | |
) | |
); | |
$metadata->mapField( | |
array( | |
'fieldName' => 'updatedAt', | |
'columnName' => 'updated_at', | |
'type' => 'datetime' | |
) | |
); | |
self::$configurations[$this->name][$metadata->getName()] = array( | |
'create' => array('createdAt'), | |
'update' => array('updatedAt') | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment