当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMetadataInfo::addLifecycleCallback方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadataInfo::addLifecycleCallback方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadataInfo::addLifecycleCallback方法的具体用法?PHP ClassMetadataInfo::addLifecycleCallback怎么用?PHP ClassMetadataInfo::addLifecycleCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Mapping\ClassMetadataInfo的用法示例。


在下文中一共展示了ClassMetadataInfo::addLifecycleCallback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadMetadata

 /**
  * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata
  */
 public static function loadMetadata(ORM\ClassMetadataInfo $metadata)
 {
     $metadata->setTableName('page');
     $metadata->setIdGeneratorType(ORM\ClassMetadataInfo::GENERATOR_TYPE_NONE);
     $metadata->setCustomRepositoryClass('Orm\\Repository\\PageRepository');
     $metadata->addLifecycleCallback('setTemplatecontentChecksumOnUpdate', 'prePersist');
     $metadata->addLifecycleCallback('setTemplatecontentChecksumOnUpdate', 'preUpdate');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'prePersist');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'preUpdate');
     $metadata->mapField(array('id' => true, 'fieldName' => 'id', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('id' => true, 'fieldName' => 'websiteid', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('fieldName' => 'templateid', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('fieldName' => 'mediaid', 'type' => 'string', 'length' => 255, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'name', 'type' => 'string', 'length' => 255));
     $metadata->mapField(array('fieldName' => 'description', 'type' => 'text'));
     $metadata->mapField(array('fieldName' => 'date', 'type' => 'bigint', 'length' => 20));
     $metadata->mapField(array('fieldName' => 'innavigation', 'type' => 'smallint', 'length' => 1));
     $metadata->mapField(array('fieldName' => 'navigationtitle', 'type' => 'string', 'length' => 255));
     $metadata->mapField(array('fieldName' => 'content', 'type' => 'text'));
     $metadata->mapField(array('fieldName' => 'templatecontent', 'type' => 'text'));
     $metadata->mapField(array('fieldName' => 'templatecontentchecksum', 'type' => 'string', 'length' => 255));
     $metadata->mapField(array('fieldName' => 'globalcontent', 'type' => 'text', 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'pagetype', 'type' => 'string', 'length' => 255, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'pageattributes', 'type' => 'text', 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'lastupdate', 'type' => 'bigint', 'default' => 0));
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:29,代码来源:Page.php

示例2: loadMetadata

 /**
  * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata
  */
 public static function loadMetadata(ORM\ClassMetadataInfo $metadata)
 {
     $metadata->setTableName('album');
     $metadata->setIdGeneratorType(ORM\ClassMetadataInfo::GENERATOR_TYPE_NONE);
     $metadata->setCustomRepositoryClass('Orm\\Repository\\AlbumRepository');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'prePersist');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'preUpdate');
     $metadata->mapField(array('id' => true, 'fieldName' => 'id', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('id' => true, 'fieldName' => 'websiteid', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('fieldName' => 'name', 'type' => 'string', 'length' => 255));
     $metadata->mapField(array('fieldName' => 'lastupdate', 'type' => 'bigint', 'default' => 0));
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:15,代码来源:Album.php

示例3: loadMetadata

 /**
  * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata
  */
 public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
 {
     $metadata->setTableName('user_group');
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_NONE);
     $metadata->setCustomRepositoryClass('Orm\\Repository\\GroupRepository');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'prePersist');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'preUpdate');
     $metadata->mapField(array('id' => true, 'fieldName' => 'id', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('id' => true, 'fieldName' => 'websiteid', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('fieldName' => 'name', 'type' => 'string', 'length' => 255));
     $metadata->mapField(array('fieldName' => 'rights', 'type' => 'text', 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'users', 'type' => 'text'));
     $metadata->mapField(array('fieldName' => 'lastupdate', 'type' => 'bigint', 'default' => 0));
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:17,代码来源:Group.php

示例4: generateBookEntityFixture

 public function generateBookEntityFixture()
 {
     $metadata = new ClassMetadataInfo($this->_namespace . '\\EntityGeneratorBook');
     $metadata->namespace = $this->_namespace;
     $metadata->customRepositoryClassName = $this->_namespace . '\\EntityGeneratorBookRepository';
     $metadata->table['name'] = 'book';
     $metadata->mapField(array('fieldName' => 'name', 'type' => 'string'));
     $metadata->mapField(array('fieldName' => 'status', 'type' => 'string', 'default' => 'published'));
     $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     $metadata->mapOneToOne(array('fieldName' => 'author', 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\EntityGeneratorAuthor', 'mappedBy' => 'book'));
     $joinColumns = array(array('name' => 'author_id', 'referencedColumnName' => 'id'));
     $metadata->mapManyToMany(array('fieldName' => 'comments', 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\EntityGeneratorComment', 'joinTable' => array('name' => 'book_comment', 'joinColumns' => array(array('name' => 'book_id', 'referencedColumnName' => 'id')), 'inverseJoinColumns' => array(array('name' => 'comment_id', 'referencedColumnName' => 'id')))));
     $metadata->addLifecycleCallback('loading', 'postLoad');
     $metadata->addLifecycleCallback('willBeRemoved', 'preRemove');
     $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
     $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
     return $metadata;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:18,代码来源:EntityGeneratorTest.php

示例5: loadMetadata

 /**
  * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata
  */
 public static function loadMetadata(ORM\ClassMetadataInfo $metadata)
 {
     $metadata->setTableName('user');
     $metadata->setIdGeneratorType(ORM\ClassMetadataInfo::GENERATOR_TYPE_NONE);
     $metadata->setCustomRepositoryClass('Orm\\Repository\\UserRepository');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'prePersist');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'preUpdate');
     $metadata->mapField(array('id' => true, 'fieldName' => 'id', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('fieldName' => 'lastname', 'type' => 'string', 'length' => 255));
     $metadata->mapField(array('fieldName' => 'firstname', 'type' => 'string', 'length' => 255));
     $metadata->mapField(array('fieldName' => 'password', 'type' => 'string', 'length' => 255));
     $metadata->mapField(array('fieldName' => 'gender', 'type' => 'string', 'length' => 10, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'email', 'type' => 'string', 'length' => 255));
     $metadata->mapField(array('fieldName' => 'language', 'type' => 'string', 'length' => 10, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'issuperuser', 'type' => 'boolean'));
     $metadata->mapField(array('fieldName' => 'isdeletable', 'type' => 'boolean'));
     $metadata->mapField(array('fieldName' => 'lastupdate', 'type' => 'bigint', 'default' => 0));
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:21,代码来源:User.php

示例6: loadMetadata

 /**
  * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata
  */
 public static function loadMetadata(ORM\ClassMetadataInfo $metadata)
 {
     $metadata->setTableName('media_item');
     $metadata->setIdGeneratorType(ORM\ClassMetadataInfo::GENERATOR_TYPE_NONE);
     $metadata->setCustomRepositoryClass('Orm\\Repository\\MediaRepository');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'prePersist');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'preUpdate');
     $metadata->mapField(array('id' => true, 'fieldName' => 'id', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('id' => true, 'fieldName' => 'websiteid', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('fieldName' => 'dateUploaded', 'type' => 'integer', 'length' => 11, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'name', 'type' => 'string', 'length' => 255, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'filename', 'type' => 'string', 'length' => 255, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'extension', 'type' => 'string', 'length' => 255, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'size', 'type' => 'bigint', 'length' => 20, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'lastmod', 'type' => 'string', 'length' => 20, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'file', 'type' => 'string', 'length' => 255, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'type', 'type' => 'string', 'length' => 255, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'mimetype', 'type' => 'string', 'length' => 255, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'albumid', 'type' => 'string', 'length' => 100, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'lastupdate', 'type' => 'bigint', 'default' => 0));
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:24,代码来源:Media.php

示例7: loadMetadata

 /**
  * @param \Doctrine\ORM\Mapping\ClassMetadataInfo|\Orm\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata
  */
 public static function loadMetadata(ORM\ClassMetadataInfo $metadata)
 {
     $metadata->setTableName('website');
     $metadata->setIdGeneratorType(ORM\ClassMetadataInfo::GENERATOR_TYPE_NONE);
     $metadata->setCustomRepositoryClass('Orm\\Repository\\WebsiteRepository');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'prePersist');
     $metadata->addLifecycleCallback('setLastupdateToNow', 'preUpdate');
     $metadata->mapField(array('id' => true, 'fieldName' => 'id', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('fieldName' => 'shortid', 'type' => 'string', 'length' => 10));
     $metadata->mapField(array('fieldName' => 'name', 'type' => 'string', 'length' => 255));
     $metadata->mapField(array('fieldName' => 'description', 'type' => 'text'));
     $metadata->mapField(array('fieldName' => 'navigation', 'type' => 'text'));
     $metadata->mapField(array('fieldName' => 'publishingenabled', 'type' => 'boolean', 'default' => false));
     $metadata->mapField(array('fieldName' => 'publish', 'type' => 'text', 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'colorscheme', 'type' => 'text'));
     $metadata->mapField(array('fieldName' => 'resolutions', 'type' => 'text'));
     $metadata->mapField(array('fieldName' => 'version', 'type' => 'integer'));
     $metadata->mapField(array('fieldName' => 'home', 'type' => 'string', 'length' => 100));
     $metadata->mapField(array('fieldName' => 'usedsetid', 'type' => 'string', 'length' => 100, 'nullable' => true));
     $metadata->mapField(array('fieldName' => 'creationmode', 'type' => 'string', 'length' => 10, 'default' => 'full'));
     $metadata->mapField(array('fieldName' => 'ismarkedfordeletion', 'type' => 'boolean'));
     $metadata->mapField(array('fieldName' => 'lastupdate', 'type' => 'bigint', 'default' => 0));
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:26,代码来源:Website.php

示例8: generateBookEntityFixture

 /**
  * @param ClassMetadataInfo[] $embeddedClasses
  *
  * @return ClassMetadataInfo
  */
 public function generateBookEntityFixture(array $embeddedClasses = array())
 {
     $metadata = new ClassMetadataInfo($this->_namespace . '\\EntityGeneratorBook');
     $metadata->namespace = $this->_namespace;
     $metadata->customRepositoryClassName = $this->_namespace . '\\EntityGeneratorBookRepository';
     $metadata->table['name'] = 'book';
     $metadata->table['uniqueConstraints']['name_uniq'] = array('columns' => array('name'));
     $metadata->table['indexes']['status_idx'] = array('columns' => array('status'));
     $metadata->mapField(array('fieldName' => 'name', 'type' => 'string'));
     $metadata->mapField(array('fieldName' => 'status', 'type' => 'string', 'options' => array('default' => 'published')));
     $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     $metadata->mapOneToOne(array('fieldName' => 'author', 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\EntityGeneratorAuthor', 'mappedBy' => 'book'));
     $joinColumns = array(array('name' => 'author_id', 'referencedColumnName' => 'id'));
     $metadata->mapManyToMany(array('fieldName' => 'comments', 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\EntityGeneratorComment', 'fetch' => ClassMetadataInfo::FETCH_EXTRA_LAZY, 'joinTable' => array('name' => 'book_comment', 'joinColumns' => array(array('name' => 'book_id', 'referencedColumnName' => 'id')), 'inverseJoinColumns' => array(array('name' => 'comment_id', 'referencedColumnName' => 'id')))));
     $metadata->addLifecycleCallback('loading', 'postLoad');
     $metadata->addLifecycleCallback('willBeRemoved', 'preRemove');
     $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
     foreach ($embeddedClasses as $fieldName => $embeddedClass) {
         $this->mapNestedEmbedded($fieldName, $metadata, $embeddedClass);
         $this->mapEmbedded($fieldName, $metadata, $embeddedClass);
     }
     $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
     return $metadata;
 }
开发者ID:selimcr,项目名称:servigases,代码行数:29,代码来源:EntityGeneratorTest.php

示例9: addLifecycleCallback

 /**
  * @param string $callback
  * @param string $event
  */
 public function addLifecycleCallback($callback, $event)
 {
     if (!$this->reflClass->hasMethod($callback) || ($this->reflClass->getMethod($callback)->getModifiers() & \ReflectionMethod::IS_PUBLIC) == 0) {
         throw MappingException::lifecycleCallbackMethodNotFound($this->name, $callback);
     }
     return parent::addLifecycleCallback($callback, $event);
 }
开发者ID:ramonornela,项目名称:doctrine2,代码行数:11,代码来源:ClassMetadata.php

示例10: evaluateLifeCycleAnnotations

 /**
  * Evaluate the lifecycle annotations and amend the metadata accordingly.
  *
  * @param \ReflectionClass $class
  * @param ClassMetadataInfo $metadata
  * @return void
  */
 protected function evaluateLifeCycleAnnotations(\ReflectionClass $class, ClassMetadataInfo $metadata)
 {
     foreach ($class->getMethods() as $method) {
         if ($method->isPublic()) {
             foreach ($this->getMethodCallbacks($method) as $value) {
                 $metadata->addLifecycleCallback($value[0], $value[1]);
             }
         }
     }
     $proxyAnnotation = $this->reader->getClassAnnotation($class, \TYPO3\Flow\Annotations\Proxy::class);
     if ($proxyAnnotation === null || $proxyAnnotation->enabled !== false) {
         // FIXME this can be removed again once Doctrine is fixed (see fixMethodsAndAdvicesArrayForDoctrineProxiesCode())
         $metadata->addLifecycleCallback('Flow_Aop_Proxy_fixMethodsAndAdvicesArrayForDoctrineProxies', Events::postLoad);
         // FIXME this can be removed again once Doctrine is fixed (see fixInjectedPropertiesForDoctrineProxiesCode())
         $metadata->addLifecycleCallback('Flow_Aop_Proxy_fixInjectedPropertiesForDoctrineProxies', Events::postLoad);
     }
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:24,代码来源:FlowAnnotationDriver.php

示例11: evaluateLifeCycleAnnotations

 /**
  * Evaluate the lifecycle annotations and amend the metadata accordingly.
  *
  * @param \ReflectionClass $class
  * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata
  * @return void
  */
 protected function evaluateLifeCycleAnnotations(\ReflectionClass $class, \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
 {
     foreach ($class->getMethods() as $method) {
         if ($method->isPublic()) {
             $annotations = $this->reader->getMethodAnnotations($method);
             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);
             }
         }
     }
     // FIXME this can be removed again once Doctrine is fixed (see fixMethodsAndAdvicesArrayForDoctrineProxiesCode())
     $metadata->addLifecycleCallback('Flow_Aop_Proxy_fixMethodsAndAdvicesArrayForDoctrineProxies', \Doctrine\ORM\Events::postLoad);
     // FIXME this can be removed again once Doctrine is fixed (see fixInjectedPropertiesForDoctrineProxiesCode())
     $metadata->addLifecycleCallback('Flow_Aop_Proxy_fixInjectedPropertiesForDoctrineProxies', \Doctrine\ORM\Events::postLoad);
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:43,代码来源:FlowAnnotationDriver.php

示例12: array

    'targetEntity' => 'Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor',
    'mappedBy' => 'book',
    'joinColumns' => array(
        array('name' => 'author_id', 'referencedColumnName' => 'id')
    ),
));
$metadata->mapManyToMany(array(
    'fieldName' => 'comments',
    'targetEntity' => 'Doctrine\Tests\ORM\Tools\EntityGeneratorComment',
    'joinTable' => array(
        'name' => 'book_comment',
        'joinColumns' => array(array('name' => 'book_id', 'referencedColumnName' => 'id')),
        'inverseJoinColumns' => array(array('name' => 'comment_id', 'referencedColumnName' => 'id')),
    ),
));
$metadata->addLifecycleCallback('loading', 'postLoad');
$metadata->addLifecycleCallback('willBeRemoved', 'preRemove');
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT);

$builder = new BaseActiveRecord($metadata);

$builder->setMappingDriver(BaseActiveRecord::MAPPING_STATIC_PHP | BaseActiveRecord::MAPPING_ANNOTATION);
$builder->setAnnotationPrefix('orm');

// using custom templates to tweak EntityManager
$builder->addTemplateDir(__DIR__ . '/templates');

// using extensions
$builder->addExtension(new Timestampable());
$builder->addExtension(new GenerationTimestamp());
开发者ID:regisg27,项目名称:Propel2,代码行数:31,代码来源:demo.php

示例13: loadMetadataForClass


//.........这里部分代码省略.........
                 $mapping['joinColumns'] = $joinColumns;
                 $mapping['mappedBy'] = $oneToOneAnnot->mappedBy;
                 $mapping['inversedBy'] = $oneToOneAnnot->inversedBy;
                 $mapping['cascade'] = $oneToOneAnnot->cascade;
                 $mapping['orphanRemoval'] = $oneToOneAnnot->orphanRemoval;
                 $mapping['fetch'] = $this->getFetchMode($className, $oneToOneAnnot->fetch);
                 $metadata->mapOneToOne($mapping);
             } else {
                 if ($oneToManyAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OneToMany')) {
                     $mapping['mappedBy'] = $oneToManyAnnot->mappedBy;
                     $mapping['targetEntity'] = $oneToManyAnnot->targetEntity;
                     $mapping['cascade'] = $oneToManyAnnot->cascade;
                     $mapping['indexBy'] = $oneToManyAnnot->indexBy;
                     $mapping['orphanRemoval'] = $oneToManyAnnot->orphanRemoval;
                     $mapping['fetch'] = $this->getFetchMode($className, $oneToManyAnnot->fetch);
                     if ($orderByAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\OrderBy')) {
                         $mapping['orderBy'] = $orderByAnnot->value;
                     }
                     $metadata->mapOneToMany($mapping);
                 } else {
                     if ($manyToOneAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\ManyToOne')) {
                         if ($idAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Id')) {
                             $mapping['id'] = true;
                         }
                         $mapping['joinColumns'] = $joinColumns;
                         $mapping['cascade'] = $manyToOneAnnot->cascade;
                         $mapping['inversedBy'] = $manyToOneAnnot->inversedBy;
                         $mapping['targetEntity'] = $manyToOneAnnot->targetEntity;
                         $mapping['fetch'] = $this->getFetchMode($className, $manyToOneAnnot->fetch);
                         $metadata->mapManyToOne($mapping);
                     } else {
                         if ($manyToManyAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\ManyToMany')) {
                             $joinTable = array();
                             if ($joinTableAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\JoinTable')) {
                                 $joinTable = array('name' => $joinTableAnnot->name, 'schema' => $joinTableAnnot->schema);
                                 foreach ($joinTableAnnot->joinColumns as $joinColumn) {
                                     $joinTable['joinColumns'][] = array('name' => $joinColumn->name, 'referencedColumnName' => $joinColumn->referencedColumnName, 'unique' => $joinColumn->unique, 'nullable' => $joinColumn->nullable, 'onDelete' => $joinColumn->onDelete, 'columnDefinition' => $joinColumn->columnDefinition);
                                 }
                                 foreach ($joinTableAnnot->inverseJoinColumns as $joinColumn) {
                                     $joinTable['inverseJoinColumns'][] = array('name' => $joinColumn->name, 'referencedColumnName' => $joinColumn->referencedColumnName, 'unique' => $joinColumn->unique, 'nullable' => $joinColumn->nullable, 'onDelete' => $joinColumn->onDelete, 'columnDefinition' => $joinColumn->columnDefinition);
                                 }
                             }
                             $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 @HasLifecycleCallbacks annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\HasLifecycleCallbacks'])) {
         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);
                 // Compatibility with Doctrine Common 3.x
                 if ($annotations && is_int(key($annotations))) {
                     foreach ($annotations as $annot) {
                         $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);
                 }
             }
         }
     }
 }
开发者ID:SerdarSanri,项目名称:doctrine-bundle,代码行数:101,代码来源:AnnotationDriver.php

示例14: addLifecycleCallbacks

 /**
  * Adds timestampable lifecycle callbacks to entity
  */
 protected function addLifecycleCallbacks()
 {
     foreach ($this->getLifecycleCallbacks() as $callback) {
         $this->classMetadata->addLifecycleCallback('updateTimestamps', $callback);
     }
 }
开发者ID:WellCommerce,项目名称:DoctrineBundle,代码行数:9,代码来源:TimestampableSubscriber.php

示例15: loadMetadataForClass


//.........这里部分代码省略.........
             if (isset($oneToManyElement['orphanRemoval'])) {
                 $mapping['orphanRemoval'] = (bool) $oneToManyElement['orphanRemoval'];
             }
             if (isset($oneToManyElement['orderBy'])) {
                 $mapping['orderBy'] = $oneToManyElement['orderBy'];
             }
             if (isset($oneToManyElement['indexBy'])) {
                 $mapping['indexBy'] = $oneToManyElement['indexBy'];
             }
             $metadata->mapOneToMany($mapping);
         }
     }
     // Evaluate manyToOne relationships
     if (isset($element['manyToOne'])) {
         foreach ($element['manyToOne'] as $name => $manyToOneElement) {
             $mapping = array('fieldName' => $name, 'targetEntity' => $manyToOneElement['targetEntity']);
             if (isset($associationIds[$mapping['fieldName']])) {
                 $mapping['id'] = true;
             }
             if (isset($manyToOneElement['fetch'])) {
                 $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\ClassMetadata::FETCH_' . $manyToOneElement['fetch']);
             }
             if (isset($manyToOneElement['inversedBy'])) {
                 $mapping['inversedBy'] = $manyToOneElement['inversedBy'];
             }
             $joinColumns = array();
             if (isset($manyToOneElement['joinColumn'])) {
                 $joinColumns[] = $this->_getJoinColumnMapping($manyToOneElement['joinColumn']);
             } else {
                 if (isset($manyToOneElement['joinColumns'])) {
                     foreach ($manyToOneElement['joinColumns'] as $name => $joinColumnElement) {
                         if (!isset($joinColumnElement['name'])) {
                             $joinColumnElement['name'] = $name;
                         }
                         $joinColumns[] = $this->_getJoinColumnMapping($joinColumnElement);
                     }
                 }
             }
             $mapping['joinColumns'] = $joinColumns;
             if (isset($manyToOneElement['cascade'])) {
                 $mapping['cascade'] = $manyToOneElement['cascade'];
             }
             $metadata->mapManyToOne($mapping);
         }
     }
     // Evaluate manyToMany relationships
     if (isset($element['manyToMany'])) {
         foreach ($element['manyToMany'] as $name => $manyToManyElement) {
             $mapping = array('fieldName' => $name, 'targetEntity' => $manyToManyElement['targetEntity']);
             if (isset($manyToManyElement['fetch'])) {
                 $mapping['fetch'] = constant('Doctrine\\ORM\\Mapping\\ClassMetadata::FETCH_' . $manyToManyElement['fetch']);
             }
             if (isset($manyToManyElement['mappedBy'])) {
                 $mapping['mappedBy'] = $manyToManyElement['mappedBy'];
             } else {
                 if (isset($manyToManyElement['joinTable'])) {
                     if (isset($manyToManyElement['inversedBy'])) {
                         $mapping['inversedBy'] = $manyToManyElement['inversedBy'];
                     }
                     $joinTableElement = $manyToManyElement['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->_getJoinColumnMapping($joinColumnElement);
                     }
                     foreach ($joinTableElement['inverseJoinColumns'] as $name => $joinColumnElement) {
                         if (!isset($joinColumnElement['name'])) {
                             $joinColumnElement['name'] = $name;
                         }
                         $joinTable['inverseJoinColumns'][] = $this->_getJoinColumnMapping($joinColumnElement);
                     }
                     $mapping['joinTable'] = $joinTable;
                 }
             }
             if (isset($manyToManyElement['cascade'])) {
                 $mapping['cascade'] = $manyToManyElement['cascade'];
             }
             if (isset($manyToManyElement['orderBy'])) {
                 $mapping['orderBy'] = $manyToManyElement['orderBy'];
             }
             if (isset($manyToManyElement['indexBy'])) {
                 $mapping['indexBy'] = $manyToManyElement['indexBy'];
             }
             $metadata->mapManyToMany($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));
             }
         }
     }
 }
开发者ID:williamamed,项目名称:Raptor2,代码行数:101,代码来源:YamlDriver.php


注:本文中的Doctrine\ORM\Mapping\ClassMetadataInfo::addLifecycleCallback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。