本文整理汇总了PHP中Doctrine\Common\Persistence\Mapping\ClassMetadata::addLifecycleCallback方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::addLifecycleCallback方法的具体用法?PHP ClassMetadata::addLifecycleCallback怎么用?PHP ClassMetadata::addLifecycleCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\Mapping\ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata::addLifecycleCallback方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadMetadataForClass
//.........这里部分代码省略.........
foreach ($xmlRoot->{'many-to-many'} as $manyToManyElement) {
$mapping = array('fieldName' => (string) $manyToManyElement['field'], 'targetEntity' => (string) $manyToManyElement['target-entity']);
if (isset($manyToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\ClassMetadata::FETCH_' . (string) $manyToManyElement['fetch']);
}
if (isset($manyToManyElement['orphan-removal'])) {
$mapping['orphanRemoval'] = $this->evaluateBoolean($manyToManyElement['orphan-removal']);
}
if (isset($manyToManyElement['mapped-by'])) {
$mapping['mappedBy'] = (string) $manyToManyElement['mapped-by'];
} else {
if (isset($manyToManyElement->{'join-table'})) {
if (isset($manyToManyElement['inversed-by'])) {
$mapping['inversedBy'] = (string) $manyToManyElement['inversed-by'];
}
$joinTableElement = $manyToManyElement->{'join-table'};
$joinTable = array('name' => (string) $joinTableElement['name']);
if (isset($joinTableElement['schema'])) {
$joinTable['schema'] = (string) $joinTableElement['schema'];
}
foreach ($joinTableElement->{'join-columns'}->{'join-column'} as $joinColumnElement) {
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement);
}
foreach ($joinTableElement->{'inverse-join-columns'}->{'join-column'} as $joinColumnElement) {
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement);
}
$mapping['joinTable'] = $joinTable;
}
}
if (isset($manyToManyElement->cascade)) {
$mapping['cascade'] = $this->_getCascadeMappings($manyToManyElement->cascade);
}
if (isset($manyToManyElement->{'order-by'})) {
$orderBy = array();
foreach ($manyToManyElement->{'order-by'}->{'order-by-field'} as $orderByField) {
$orderBy[(string) $orderByField['name']] = (string) $orderByField['direction'];
}
$mapping['orderBy'] = $orderBy;
}
if (isset($manyToManyElement['index-by'])) {
$mapping['indexBy'] = (string) $manyToManyElement['index-by'];
} else {
if (isset($manyToManyElement->{'index-by'})) {
throw new \InvalidArgumentException("<index-by /> is not a valid tag");
}
}
$metadata->mapManyToMany($mapping);
}
}
// Evaluate association-overrides
if (isset($xmlRoot->{'attribute-overrides'})) {
foreach ($xmlRoot->{'attribute-overrides'}->{'attribute-override'} as $overrideElement) {
$fieldName = (string) $overrideElement['name'];
foreach ($overrideElement->field as $field) {
$mapping = $this->columnToArray($field);
$mapping['fieldName'] = $fieldName;
$metadata->setAttributeOverride($fieldName, $mapping);
}
}
}
// Evaluate association-overrides
if (isset($xmlRoot->{'association-overrides'})) {
foreach ($xmlRoot->{'association-overrides'}->{'association-override'} as $overrideElement) {
$fieldName = (string) $overrideElement['name'];
$override = array();
// Check for join-columns
if (isset($overrideElement->{'join-columns'})) {
$joinColumns = array();
foreach ($overrideElement->{'join-columns'}->{'join-column'} as $joinColumnElement) {
$joinColumns[] = $this->joinColumnToArray($joinColumnElement);
}
$override['joinColumns'] = $joinColumns;
}
// Check for join-table
if ($overrideElement->{'join-table'}) {
$joinTable = null;
$joinTableElement = $overrideElement->{'join-table'};
$joinTable = array('name' => (string) $joinTableElement['name'], 'schema' => (string) $joinTableElement['schema']);
if (isset($joinTableElement->{'join-columns'})) {
foreach ($joinTableElement->{'join-columns'}->{'join-column'} as $joinColumnElement) {
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement);
}
}
if (isset($joinTableElement->{'inverse-join-columns'})) {
foreach ($joinTableElement->{'inverse-join-columns'}->{'join-column'} as $joinColumnElement) {
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement);
}
}
$override['joinTable'] = $joinTable;
}
$metadata->setAssociationOverride($fieldName, $override);
}
}
// Evaluate <lifecycle-callbacks...>
if (isset($xmlRoot->{'lifecycle-callbacks'})) {
foreach ($xmlRoot->{'lifecycle-callbacks'}->{'lifecycle-callback'} as $lifecycleCallback) {
$metadata->addLifecycleCallback((string) $lifecycleCallback['method'], constant('Doctrine\\ORM\\Events::' . (string) $lifecycleCallback['type']));
}
}
}
示例2: loadMetadataForClass
//.........这里部分代码省略.........
$joinColumnElement['name'] = $joinColumnName;
}
}
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement);
}
$mapping['joinTable'] = $joinTable;
}
}
if (isset($manyToManyElement['inversedBy'])) {
$mapping['inversedBy'] = $manyToManyElement['inversedBy'];
}
if (isset($manyToManyElement['cascade'])) {
$mapping['cascade'] = $manyToManyElement['cascade'];
}
if (isset($manyToManyElement['orderBy'])) {
$mapping['orderBy'] = $manyToManyElement['orderBy'];
}
if (isset($manyToManyElement['indexBy'])) {
$mapping['indexBy'] = $manyToManyElement['indexBy'];
}
if (isset($manyToManyElement['orphanRemoval'])) {
$mapping['orphanRemoval'] = (bool) $manyToManyElement['orphanRemoval'];
}
$metadata->mapManyToMany($mapping);
// Evaluate second level cache
if (isset($manyToManyElement['cache'])) {
$metadata->enableAssociationCache($mapping['fieldName'], $this->cacheToArray($manyToManyElement['cache']));
}
}
}
// Evaluate associationOverride
if (isset($element['associationOverride']) && is_array($element['associationOverride'])) {
foreach ($element['associationOverride'] as $fieldName => $associationOverrideElement) {
$override = array();
// Check for joinColumn
if (isset($associationOverrideElement['joinColumn'])) {
$joinColumns = array();
foreach ($associationOverrideElement['joinColumn'] as $name => $joinColumnElement) {
if (!isset($joinColumnElement['name'])) {
$joinColumnElement['name'] = $name;
}
$joinColumns[] = $this->joinColumnToArray($joinColumnElement);
}
$override['joinColumns'] = $joinColumns;
}
// Check for joinTable
if (isset($associationOverrideElement['joinTable'])) {
$joinTableElement = $associationOverrideElement['joinTable'];
$joinTable = array('name' => $joinTableElement['name']);
if (isset($joinTableElement['schema'])) {
$joinTable['schema'] = $joinTableElement['schema'];
}
foreach ($joinTableElement['joinColumns'] as $name => $joinColumnElement) {
if (!isset($joinColumnElement['name'])) {
$joinColumnElement['name'] = $name;
}
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement);
}
foreach ($joinTableElement['inverseJoinColumns'] as $name => $joinColumnElement) {
if (!isset($joinColumnElement['name'])) {
$joinColumnElement['name'] = $name;
}
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement);
}
$override['joinTable'] = $joinTable;
}
$metadata->setAssociationOverride($fieldName, $override);
}
}
// Evaluate associationOverride
if (isset($element['attributeOverride']) && is_array($element['attributeOverride'])) {
foreach ($element['attributeOverride'] as $fieldName => $attributeOverrideElement) {
$mapping = $this->columnToArray($fieldName, $attributeOverrideElement);
$metadata->setAttributeOverride($fieldName, $mapping);
}
}
// Evaluate lifeCycleCallbacks
if (isset($element['lifecycleCallbacks'])) {
foreach ($element['lifecycleCallbacks'] as $type => $methods) {
foreach ($methods as $method) {
$metadata->addLifecycleCallback($method, constant('Doctrine\\ORM\\Events::' . $type));
}
}
}
// Evaluate entityListeners
if (isset($element['entityListeners'])) {
foreach ($element['entityListeners'] as $className => $entityListener) {
// Evaluate the listener using naming convention.
if (empty($entityListener)) {
EntityListenerBuilder::bindEntityListener($metadata, $className);
continue;
}
foreach ($entityListener as $eventName => $callbackElement) {
foreach ($callbackElement as $methodName) {
$metadata->addEntityListener($eventName, $className, $methodName);
}
}
}
}
}
示例3: loadMetadataForClass
//.........这里部分代码省略.........
}
if (null !== $documentAnnot->mixins) {
$metadata->setMixins($documentAnnot->mixins);
}
if (null !== $documentAnnot->inheritMixins) {
$metadata->setInheritMixins($documentAnnot->inheritMixins);
}
if (null !== $documentAnnot->nodeType) {
$metadata->setNodeType($documentAnnot->nodeType);
}
if (null !== $documentAnnot->repositoryClass) {
$metadata->setCustomRepositoryClassName($documentAnnot->repositoryClass);
}
if (null !== $documentAnnot->translator) {
$metadata->setTranslator($documentAnnot->translator);
}
foreach ($reflClass->getProperties() as $property) {
if ($metadata->isInheritedField($property->name) && $metadata->name !== $property->getDeclaringClass()->getName()) {
continue;
}
$mapping = array();
$mapping['fieldName'] = $property->getName();
foreach ($this->reader->getPropertyAnnotations($property) as $fieldAnnot) {
if ($fieldAnnot instanceof ODM\Property) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapField($mapping);
} elseif ($fieldAnnot instanceof ODM\Id) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapId($mapping);
} elseif ($fieldAnnot instanceof ODM\Node) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapNode($mapping);
} elseif ($fieldAnnot instanceof ODM\Nodename) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapNodename($mapping);
} elseif ($fieldAnnot instanceof ODM\ParentDocument) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
$metadata->mapParentDocument($mapping);
} elseif ($fieldAnnot instanceof ODM\Child) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
$metadata->mapChild($mapping);
} elseif ($fieldAnnot instanceof ODM\Children) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
$metadata->mapChildren($mapping);
} elseif ($fieldAnnot instanceof ODM\ReferenceOne) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
$metadata->mapManyToOne($mapping);
} elseif ($fieldAnnot instanceof ODM\ReferenceMany) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
$metadata->mapManyToMany($mapping);
} elseif ($fieldAnnot instanceof ODM\Referrers) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
$metadata->mapReferrers($mapping);
} elseif ($fieldAnnot instanceof ODM\MixedReferrers) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapMixedReferrers($mapping);
} elseif ($fieldAnnot instanceof ODM\Locale) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapLocale($mapping);
} elseif ($fieldAnnot instanceof ODM\Depth) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapDepth($mapping);
} elseif ($fieldAnnot instanceof ODM\VersionName) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapVersionName($mapping);
} elseif ($fieldAnnot instanceof ODM\VersionCreated) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapVersionCreated($mapping);
}
}
}
foreach ($reflClass->getMethods() as $method) {
if ($method->isPublic() && $method->getDeclaringClass()->getName() == $metadata->name) {
foreach ($this->reader->getMethodAnnotations($method) as $annot) {
if ($annot instanceof ODM\PrePersist) {
$metadata->addLifecycleCallback($method->getName(), Event::prePersist);
} elseif ($annot instanceof ODM\PostPersist) {
$metadata->addLifecycleCallback($method->getName(), Event::postPersist);
} elseif ($annot instanceof ODM\PreUpdate) {
$metadata->addLifecycleCallback($method->getName(), Event::preUpdate);
} elseif ($annot instanceof ODM\PostUpdate) {
$metadata->addLifecycleCallback($method->getName(), Event::postUpdate);
} elseif ($annot instanceof ODM\PreRemove) {
$metadata->addLifecycleCallback($method->getName(), Event::preRemove);
} elseif ($annot instanceof ODM\PostRemove) {
$metadata->addLifecycleCallback($method->getName(), Event::postRemove);
} elseif ($annot instanceof ODM\PostLoad) {
$metadata->addLifecycleCallback($method->getName(), Event::postLoad);
}
}
}
}
$metadata->validateClassMapping();
}
示例4: addLifecycleCallbacks
/**
* Adds timestampable lifecycle callbacks to entity
*/
protected function addLifecycleCallbacks()
{
foreach ($this->getLifecycleCallbacks() as $callback) {
$this->classMetadata->addLifecycleCallback('updateTimestamps', $callback);
}
}
示例5: loadMetadataForClass
//.........这里部分代码省略.........
}
$mapping['joinTable'] = $joinTable;
$mapping['targetEntity'] = $manyToManyAnnot->targetEntity;
$mapping['mappedBy'] = $manyToManyAnnot->mappedBy;
$mapping['inversedBy'] = $manyToManyAnnot->inversedBy;
$mapping['cascade'] = $manyToManyAnnot->cascade;
$mapping['indexBy'] = $manyToManyAnnot->indexBy;
$mapping['orphanRemoval'] = $manyToManyAnnot->orphanRemoval;
$mapping['fetch'] = $this->getFetchMode($className, $manyToManyAnnot->fetch);
if ($orderByAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OrderBy')) {
$mapping['orderBy'] = $orderByAnnot->value;
}
$metadata->mapManyToMany($mapping);
}
}
}
}
}
}
// Evaluate AssociationOverrides annotation
if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\AssociationOverrides'])) {
$associationOverridesAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\AssociationOverrides'];
foreach ($associationOverridesAnnot->value as $associationOverride) {
$override = array();
$fieldName = $associationOverride->name;
// Check for JoinColummn/JoinColumns annotations
if ($associationOverride->joinColumns) {
$joinColumns = array();
foreach ($associationOverride->joinColumns as $joinColumn) {
$joinColumns[] = $this->joinColumnToArray($joinColumn);
}
$override['joinColumns'] = $joinColumns;
}
// Check for JoinTable annotations
if ($associationOverride->joinTable) {
$joinTable = null;
$joinTableAnnot = $associationOverride->joinTable;
$joinTable = array('name' => $joinTableAnnot->name, 'schema' => $joinTableAnnot->schema);
foreach ($joinTableAnnot->joinColumns as $joinColumn) {
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn);
}
foreach ($joinTableAnnot->inverseJoinColumns as $joinColumn) {
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumn);
}
$override['joinTable'] = $joinTable;
}
$metadata->setAssociationOverride($fieldName, $override);
}
}
// Evaluate AttributeOverrides annotation
if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\AttributeOverrides'])) {
$attributeOverridesAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\AttributeOverrides'];
foreach ($attributeOverridesAnnot->value as $attributeOverrideAnnot) {
$attributeOverride = $this->columnToArray($attributeOverrideAnnot->name, $attributeOverrideAnnot->column);
$metadata->setAttributeOverride($attributeOverrideAnnot->name, $attributeOverride);
}
}
// Evaluate @HasLifecycleCallbacks annotation
if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\HasLifecycleCallbacks'])) {
/* @var $method \ReflectionMethod */
foreach ($class->getMethods() as $method) {
// filter for the declaring class only, callbacks from parents will already be registered.
if ($method->isPublic() && $method->getDeclaringClass()->getName() == $class->name) {
$annotations = $this->reader->getMethodAnnotations($method);
if ($annotations) {
foreach ($annotations as $key => $annot) {
if (!is_numeric($key)) {
continue;
}
$annotations[get_class($annot)] = $annot;
}
}
if (isset($annotations['Doctrine\\ORM\\Mapping\\PrePersist'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::prePersist);
}
if (isset($annotations['Doctrine\\ORM\\Mapping\\PostPersist'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postPersist);
}
if (isset($annotations['Doctrine\\ORM\\Mapping\\PreUpdate'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preUpdate);
}
if (isset($annotations['Doctrine\\ORM\\Mapping\\PostUpdate'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postUpdate);
}
if (isset($annotations['Doctrine\\ORM\\Mapping\\PreRemove'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preRemove);
}
if (isset($annotations['Doctrine\\ORM\\Mapping\\PostRemove'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postRemove);
}
if (isset($annotations['Doctrine\\ORM\\Mapping\\PostLoad'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::postLoad);
}
if (isset($annotations['Doctrine\\ORM\\Mapping\\PreFlush'])) {
$metadata->addLifecycleCallback($method->getName(), \Doctrine\ORM\Events::preFlush);
}
}
}
}
}
示例6: loadMetadataForClass
/**
* {@inheritdoc}
*/
public function loadMetadataForClass($className, ClassMetadata $metadata)
{
$reflClass = $metadata->getReflectionClass();
$documentAnnots = array();
foreach ($this->reader->getClassAnnotations($reflClass) as $annot) {
foreach ($this->entityAnnotationClasses as $annotClass => $i) {
if ($annot instanceof $annotClass) {
$documentAnnots[$i] = $annot;
}
}
}
if (!$documentAnnots) {
throw MappingException::classIsNotAValidDocument($className);
}
// find the winning document annotation
ksort($documentAnnots);
$documentAnnot = reset($documentAnnots);
if (isset($documentAnnot->versionable) && $documentAnnot->versionable) {
$metadata->setVersioned($documentAnnot->versionable);
}
$metadata->setNodeType($documentAnnot->nodeType);
if (isset($documentAnnot->referenceable) && $documentAnnot->referenceable) {
$metadata->setReferenceable(true);
}
if ($documentAnnot->repositoryClass) {
$metadata->setCustomRepositoryClassName($documentAnnot->repositoryClass);
}
if ($documentAnnot->translator) {
$metadata->setTranslator($documentAnnot->translator);
}
foreach ($reflClass->getProperties() as $property) {
if ($metadata->isMappedSuperclass && !$property->isPrivate() || $metadata->isInheritedField($property->name) && $metadata->name !== $property->getDeclaringClass()->getName()) {
continue;
}
$mapping = array();
$mapping['fieldName'] = $property->getName();
foreach ($this->reader->getPropertyAnnotations($property) as $fieldAnnot) {
if ($fieldAnnot instanceof ODM\Property) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapField($mapping);
} elseif ($fieldAnnot instanceof ODM\Id) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapId($mapping);
} elseif ($fieldAnnot instanceof ODM\Node) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapNode($mapping);
} elseif ($fieldAnnot instanceof ODM\Nodename) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapNodename($mapping);
} elseif ($fieldAnnot instanceof ODM\ParentDocument) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapParentDocument($mapping);
} elseif ($fieldAnnot instanceof ODM\Child) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapChild($mapping);
} elseif ($fieldAnnot instanceof ODM\Children) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapChildren($mapping);
} elseif ($fieldAnnot instanceof ODM\ReferenceOne) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapManyToOne($mapping);
} elseif ($fieldAnnot instanceof ODM\ReferenceMany) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapManyToMany($mapping);
} elseif ($fieldAnnot instanceof ODM\Referrers) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapReferrers($mapping);
} elseif ($fieldAnnot instanceof ODM\Locale) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapLocale($mapping);
} elseif ($fieldAnnot instanceof ODM\VersionName) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapVersionName($mapping);
} elseif ($fieldAnnot instanceof ODM\VersionCreated) {
$mapping = array_merge($mapping, (array) $fieldAnnot);
$metadata->mapVersionCreated($mapping);
}
if (!isset($mapping['name'])) {
$mapping['name'] = $property->getName();
}
}
}
foreach ($reflClass->getMethods() as $method) {
if ($method->isPublic() && $method->getDeclaringClass()->getName() == $metadata->name) {
foreach ($this->reader->getMethodAnnotations($method) as $annot) {
if ($annot instanceof ODM\PrePersist) {
$metadata->addLifecycleCallback($method->getName(), Event::prePersist);
} elseif ($annot instanceof ODM\PostPersist) {
$metadata->addLifecycleCallback($method->getName(), Event::postPersist);
} elseif ($annot instanceof ODM\PreUpdate) {
$metadata->addLifecycleCallback($method->getName(), Event::preUpdate);
} elseif ($annot instanceof ODM\PostUpdate) {
$metadata->addLifecycleCallback($method->getName(), Event::postUpdate);
} elseif ($annot instanceof ODM\PreRemove) {
$metadata->addLifecycleCallback($method->getName(), Event::preRemove);
} elseif ($annot instanceof ODM\PostRemove) {
$metadata->addLifecycleCallback($method->getName(), Event::postRemove);
//.........这里部分代码省略.........