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


PHP MappingException::entityListenerClassNotFound方法代码示例

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


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

示例1: bindEntityListener

 /**
  * Lookup the entity class to find methods that match to event lifecycle names
  *
  * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata     The entity metadata.
  * @param string $className                                 The listener class name.
  *
  * @throws \Doctrine\ORM\Mapping\MappingException           When the listener class not found.
  */
 public static function bindEntityListener(ClassMetadata $metadata, $className)
 {
     $class = $metadata->fullyQualifiedClassName($className);
     if (!class_exists($class)) {
         throw MappingException::entityListenerClassNotFound($class, $className);
     }
     foreach (get_class_methods($class) as $method) {
         if (!isset(self::$events[$method])) {
             continue;
         }
         $metadata->addEntityListener($method, $class, $method);
     }
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:21,代码来源:EntityListenerBuilder.php

示例2: evaluateEntityListenersAnnotation

 /**
  * Evaluate the EntityListeners annotation and amend the metadata accordingly.
  *
  * @param \ReflectionClass $class
  * @param OrmClassMetadata $metadata
  * @param array $classAnnotations
  * @return void
  * @throws MappingException
  */
 protected function evaluateEntityListenersAnnotation(\ReflectionClass $class, OrmClassMetadata $metadata, array $classAnnotations)
 {
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\EntityListeners'])) {
         $entityListenersAnnotation = $classAnnotations['Doctrine\\ORM\\Mapping\\EntityListeners'];
         foreach ($entityListenersAnnotation->value as $item) {
             $listenerClassName = $metadata->fullyQualifiedClassName($item);
             if (!class_exists($listenerClassName)) {
                 throw MappingException::entityListenerClassNotFound($listenerClassName, $class->getName());
             }
             $hasMapping = false;
             foreach ($class->getMethods() as $method) {
                 if ($method->isPublic()) {
                     // find method callbacks.
                     $callbacks = $this->getMethodCallbacks($method);
                     $hasMapping = $hasMapping ?: !empty($callbacks);
                     foreach ($callbacks as $value) {
                         $metadata->addEntityListener($value[1], $listenerClassName, $value[0]);
                     }
                 }
             }
             // Evaluate the listener using naming convention.
             if ($hasMapping === false) {
                 EntityListenerBuilder::bindEntityListener($metadata, $listenerClassName);
             }
         }
     }
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:36,代码来源:FlowAnnotationDriver.php

示例3: 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);
                         } else {
                             if ($embeddedAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\\ORM\\Mapping\\Embedded')) {
                                 $mapping['class'] = $embeddedAnnot->class;
                                 $mapping['columnPrefix'] = $embeddedAnnot->columnPrefix;
                                 $metadata->mapEmbedded($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 JoinColumn/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) {
                 $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;
             }
             // Check for inversedBy
             if ($associationOverride->inversedBy) {
                 $override['inversedBy'] = $associationOverride->inversedBy;
             }
             $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 EntityListeners annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\EntityListeners'])) {
         $entityListenersAnnot = $classAnnotations['Doctrine\\ORM\\Mapping\\EntityListeners'];
         foreach ($entityListenersAnnot->value as $item) {
             $listenerClassName = $metadata->fullyQualifiedClassName($item);
             if (!class_exists($listenerClassName)) {
                 throw MappingException::entityListenerClassNotFound($listenerClassName, $className);
             }
             $hasMapping = false;
             $listenerClass = new \ReflectionClass($listenerClassName);
             /* @var $method \ReflectionMethod */
             foreach ($listenerClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
                 // find method callbacks.
                 $callbacks = $this->getMethodCallbacks($method);
                 $hasMapping = $hasMapping ?: !empty($callbacks);
                 foreach ($callbacks as $value) {
                     $metadata->addEntityListener($value[1], $listenerClassName, $value[0]);
                 }
             }
             // Evaluate the listener using naming convention.
             if (!$hasMapping) {
                 EntityListenerBuilder::bindEntityListener($metadata, $listenerClassName);
             }
         }
     }
     // Evaluate @HasLifecycleCallbacks annotation
     if (isset($classAnnotations['Doctrine\\ORM\\Mapping\\HasLifecycleCallbacks'])) {
         /* @var $method \ReflectionMethod */
         foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
             foreach ($this->getMethodCallbacks($method) as $value) {
                 $metadata->addLifecycleCallback($value[0], $value[1]);
             }
         }
     }
 }
开发者ID:aschempp,项目名称:doctrine2,代码行数:101,代码来源:AnnotationDriver.php

示例4: addEntityListener

 /**
  * Adds a entity listener for entities of this class.
  *
  * @param string $eventName The entity lifecycle event.
  * @param string $class     The listener class.
  * @param string $method    The listener callback method.
  *
  * @throws \Doctrine\ORM\Mapping\MappingException
  */
 public function addEntityListener($eventName, $class, $method)
 {
     $class = $this->fullyQualifiedClassName($class);
     $listener = array('class' => $class, 'method' => $method);
     if (!class_exists($class)) {
         throw MappingException::entityListenerClassNotFound($class, $this->name);
     }
     if (!method_exists($class, $method)) {
         throw MappingException::entityListenerMethodNotFound($class, $method, $this->name);
     }
     if (isset($this->entityListeners[$eventName]) && in_array($listener, $this->entityListeners[$eventName])) {
         throw MappingException::duplicateEntityListener($class, $method, $this->name);
     }
     $this->entityListeners[$eventName][] = $listener;
 }
开发者ID:guillaumeprost,项目名称:ExerciceC2IS,代码行数:24,代码来源:ClassMetadataInfo.php


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