Doctrine\OXM\Mapping\ClassMetadataInfo::addLifecycleCallback PHP Метод

addLifecycleCallback() публичный Метод

Note: If the same callback is registered more than once, the old one will be overridden.
public addLifecycleCallback ( string $callback, string $event )
$callback string
$event string
    public function addLifecycleCallback($callback, $event)
    {
        $this->lifecycleCallbacks[$event][] = $callback;
    }

Usage Example

Пример #1
0
 public static function loadMetadata(ClassMetadataInfo $metadata)
 {
     $metadata->setXmlName('cms-user');
     $metadata->isRoot = true;
     $metadata->setXmlNamespaces(array(array('url' => 'http://www.schema.com/foo', 'prefix' => 'foo'), array('url' => 'http://www.schema.com/bar', 'prefix' => 'bar')));
     $metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist');
     $metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist');
     $metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist');
     $metadata->addLifecycleCallback('doStuffOnPreMarshal', 'preMarshal');
     $metadata->mapField(array('fieldName' => 'id', 'id' => true, 'type' => 'string', 'node' => 'attribute'));
     $metadata->mapField(array('fieldName' => 'name', 'type' => 'string', 'node' => 'text', 'required' => true, 'setMethod' => 'setUsername', 'getMethod' => 'getUsername'));
     $metadata->mapField(array('fieldName' => 'comments', 'type' => 'string', 'node' => 'text', 'collection' => true, 'wrapper' => 'comments', 'name' => 'comment'));
 }
All Usage Examples Of Doctrine\OXM\Mapping\ClassMetadataInfo::addLifecycleCallback