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


PHP Mapping\MappingException类代码示例

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


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

示例1: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
 {
     if (null === $this->mappingData) {
         $this->loadMappingData();
     }
     $shortName = $this->getShortName($className);
     if (!isset($this->mappingData[$shortName])) {
         throw new MappingException(sprintf('No mapping found for class "%s".', $className));
     }
     $mapping = array_merge(array('type' => 'entity', 'table' => $this->tableize($shortName), 'readOnly' => false, 'repositoryClass' => null), $this->mappingData[$shortName]);
     switch ($mapping['type']) {
         case 'entity':
             $metadata->setCustomRepositoryClass($mapping['repositoryClass']);
             if ($mapping['readOnly']) {
                 $metadata->markReadOnly();
             }
             break;
         case 'mappedSuperclass':
             $metadata->isMappedSuperclass = true;
             break;
         default:
             throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
     }
     $metadata->setTableName($mapping['table']);
     // map fields
     foreach ($mapping['fields'] as $field => $fieldMapping) {
         $this->mapField($field, $fieldMapping, $metadata);
     }
     if (0 === count($metadata->getIdentifier())) {
         $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     }
 }
开发者ID:ruian,项目名称:KnpRadBundle,代码行数:35,代码来源:YamlDriver.php

示例2:

 function it_checks_a_non_existent_mapping_relationship($classMetadata, ConfigurationInterface $configuration)
 {
     $configuration->getName()->willReturn('foo');
     $classMetadata->getAssociationMapping('foo')->willThrow(MappingException::mappingNotFound('spec\\Pim\\Bundle\\ReferenceDataBundle\\RequirementChecker\\CustomValidProductValue', 'foo'));
     $this->check($configuration)->shouldReturn(false);
     $this->getFailure()->shouldReturn("No mapping found for field 'foo' on class " . "'spec\\Pim\\Bundle\\ReferenceDataBundle\\RequirementChecker\\CustomValidProductValue'.");
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:ProductValueRelationshipCheckerSpec.php

示例3: getAllClassNames

 /**
  * {@inheritDoc}
  * @todo Same code exists in AnnotationDriver, should we re-use it somehow or not worry about it?
  */
 public function getAllClassNames()
 {
     if ($this->_classNames !== null) {
         return $this->_classNames;
     }
     if (!$this->_paths) {
         throw MappingException::pathRequired();
     }
     $classes = array();
     $includedFiles = array();
     foreach ($this->_paths as $path) {
         if (!is_dir($path)) {
             throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
         }
         $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
         foreach ($iterator as $file) {
             if (($fileName = $file->getBasename($this->_fileExtension)) == $file->getBasename()) {
                 continue;
             }
             $sourceFile = realpath($file->getPathName());
             require_once $sourceFile;
             $includedFiles[] = $sourceFile;
         }
     }
     $declared = get_declared_classes();
     foreach ($declared as $className) {
         $rc = new \ReflectionClass($className);
         $sourceFile = $rc->getFileName();
         if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) {
             $classes[] = $className;
         }
     }
     $this->_classNames = $classes;
     return $classes;
 }
开发者ID:michaelnavarro,项目名称:zc,代码行数:39,代码来源:StaticPHPDriver.php

示例4: getAllClassNames

 /**
  * Get all class names.
  *
  * @return string[]
  */
 public function getAllClassNames()
 {
     if (!$this->paths) {
         throw MappingException::pathRequired();
     }
     $classes = [];
     $includedFiles = [];
     foreach ($this->paths as $path) {
         if (!is_dir($path)) {
             throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
         }
         $iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY), '/^.+\\/Entity\\/.+\\.php$/i', \RecursiveRegexIterator::GET_MATCH);
         foreach ($iterator as $file) {
             $sourceFile = realpath($file[0]);
             require_once $sourceFile;
             $includedFiles[] = $sourceFile;
         }
     }
     $declared = get_declared_classes();
     foreach ($declared as $className) {
         $rc = new \ReflectionClass($className);
         $sourceFile = $rc->getFileName();
         if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) {
             $classes[] = $className;
         }
     }
     return $classes;
 }
开发者ID:victoire,项目名称:victoire,代码行数:33,代码来源:AnnotationDriver.php

示例5: getClassMetadata

 /**
  * Gets the metadata of a class.
  *
  * @param string $class A class name
  * @param string $path  The path where the class is stored (if known)
  *
  * @return ClassMetadataCollection A ClassMetadataCollection instance
  */
 public function getClassMetadata($class, $path = null)
 {
     $metadata = $this->getMetadataForClass($class);
     if (!$metadata->getMetadata()) {
         throw MappingException::classIsNotAValidEntityOrMappedSuperClass($class);
     }
     $this->findNamespaceAndPathForMetadata($metadata);
     return $metadata;
 }
开发者ID:laubosslink,项目名称:lab,代码行数:17,代码来源:MetadataFactory.php

示例6: loadMetadataForClass

 /**
  * Loads the metadata for the specified class into the provided container.
  *
  * @param string $className
  * @param ClassMetadataInfo $metadata
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
 {
     foreach ($this->_drivers as $namespace => $driver) {
         if (strpos($className, $namespace) === 0) {
             $driver->loadMetadataForClass($className, $metadata);
             return;
         }
     }
     throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
 }
开发者ID:pabloasc,项目名称:test_social,代码行数:16,代码来源:DriverChain.php

示例7: findMappingFile

 /**
  * {@inheritDoc}
  */
 public function findMappingFile($className)
 {
     if (!$this->fileExists($className)) {
         throw MappingException::mappingFileNotFound($className, $this->paths[0]);
     }
     if (isset(self::$pathsMap[$className])) {
         $this->paths = self::$pathsMap[$className];
     }
     return $this->paths[0];
 }
开发者ID:nacmartin,项目名称:SimpleDoctrineMapping,代码行数:13,代码来源:SimpleDoctrineMappingLocator.php

示例8: 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

示例9: _findMappingFile

 protected function _findMappingFile($className)
 {
     foreach ($this->_paths as $prefix => $path) {
         if (0 !== strpos($className, $prefix . '\\')) {
             continue;
         }
         $filename = $path . '/' . strtr(substr($className, strlen($prefix) + 1), '\\', '.') . $this->_fileExtension;
         if (file_exists($filename)) {
             return $filename;
         }
         throw MappingException::mappingFileNotFound($className, $filename);
     }
     throw MappingException::mappingFileNotFound($className, substr($className, strrpos($className, '\\') + 1) . $this->_fileExtension);
 }
开发者ID:rfc1483,项目名称:blog,代码行数:14,代码来源:XmlDriver.php

示例10: getClassMetadata

 /**
  * Gets the metadata of a class.
  *
  * @param string $class A class name
  * @param string $path  The path where the class is stored (if known)
  *
  * @return ClassMetadataCollection A ClassMetadataCollection instance
  */
 public function getClassMetadata($class, $path = null)
 {
     $metadata = $this->getMetadataForClass($class);
     if (!$metadata->getMetadata()) {
         throw MappingException::classIsNotAValidEntityOrMappedSuperClass($class);
     }
     $all = $metadata->getMetadata();
     if (class_exists($class)) {
         $r = $all[0]->getReflectionClass();
         $path = $this->getBasePathForClass($class, $r->getNamespacename(), dirname($r->getFilename()));
     } elseif (!$path) {
         throw new \RuntimeException(sprintf('Unable to determine where to save the "%s" class (use the --path option).', $class));
     }
     $metadata->setPath($path);
     $metadata->setNamespace($r->getNamespacename());
     return $metadata;
 }
开发者ID:laiello,项目名称:mediathequescrum,代码行数:25,代码来源:MetadataFactory.php

示例11: setVersionMapping

 /**
  * Sets the version field mapping used for versioning. Sets the default
  * value to use depending on the column type.
  *
  * @param array $mapping   The version field mapping array
  * @throws MappingException
  * @return void
  */
 public function setVersionMapping(array &$mapping)
 {
     $this->isVersioned = true;
     $this->versionField = $mapping['fieldName'];
     if (!isset($mapping['default'])) {
         if (in_array($mapping['type'], array('integer', 'bigint', 'smallint'))) {
             $mapping['default'] = 1;
         } else {
             if ($mapping['type'] == 'datetime') {
                 $mapping['default'] = 'CURRENT_TIMESTAMP';
             } else {
                 throw MappingException::unsupportedOptimisticLockingType($this->name, $mapping['fieldName'], $mapping['type']);
             }
         }
     }
 }
开发者ID:alexanderwsp-git,项目名称:columbus,代码行数:24,代码来源:ClassMetadataInfo.php

示例12: getManyToManyStatement

    /**
     * @param array    $assoc
     * @param object   $sourceEntity
     * @param int|null $offset
     * @param int|null $limit
     *
     * @return \Doctrine\DBAL\Driver\Statement
     *
     * @throws \Doctrine\ORM\Mapping\MappingException
     */
    private function getManyToManyStatement(array $assoc, $sourceEntity, $offset = null, $limit = null)
    {
        $sourceClass    = $this->em->getClassMetadata($assoc['sourceEntity']);
        $class          = $sourceClass;
        $association    = $assoc;
        $criteria       = array();


        if ( ! $assoc['isOwningSide']) {
            $class       = $this->em->getClassMetadata($assoc['targetEntity']);
            $association = $class->associationMappings[$assoc['mappedBy']];
        }

        $joinColumns = $assoc['isOwningSide']
            ? $association['joinTable']['joinColumns']
            : $association['joinTable']['inverseJoinColumns'];

        $quotedJoinTable = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform);

        foreach ($joinColumns as $joinColumn) {

            $sourceKeyColumn    = $joinColumn['referencedColumnName'];
            $quotedKeyColumn    = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);

            switch (true) {
                case $sourceClass->containsForeignIdentifier:
                    $field = $sourceClass->getFieldForColumn($sourceKeyColumn);
                    $value = $sourceClass->reflFields[$field]->getValue($sourceEntity);

                    if (isset($sourceClass->associationMappings[$field])) {
                        $value = $this->em->getUnitOfWork()->getEntityIdentifier($value);
                        $value = $value[$this->em->getClassMetadata($sourceClass->associationMappings[$field]['targetEntity'])->identifier[0]];
                    }

                    break;

                case isset($sourceClass->fieldNames[$sourceKeyColumn]):
                    $field = $sourceClass->fieldNames[$sourceKeyColumn];
                    $value = $sourceClass->reflFields[$field]->getValue($sourceEntity);

                    break;

                default:
                    throw MappingException::joinColumnMustPointToMappedField(
                        $sourceClass->name, $sourceKeyColumn
                    );
            }

            $criteria[$quotedJoinTable . '.' . $quotedKeyColumn] = $value;
        }

        $sql = $this->getSelectSQL($criteria, $assoc, 0, $limit, $offset);
        list($params, $types) = $this->expandParameters($criteria);

        return $this->conn->executeQuery($sql, $params, $types);
    }
开发者ID:nattaphat,项目名称:hgis,代码行数:66,代码来源:BasicEntityPersister.php

示例13: loadMetadataForClass

 /**
  * {@inheritDoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $metadata)
 {
     /* @var $metadata \Doctrine\ORM\Mapping\ClassMetadataInfo */
     /* @var $xmlRoot SimpleXMLElement */
     $xmlRoot = $this->getElement($className);
     if ($xmlRoot->getName() == 'entity') {
         if (isset($xmlRoot['repository-class'])) {
             $metadata->setCustomRepositoryClass((string) $xmlRoot['repository-class']);
         }
         if (isset($xmlRoot['read-only']) && $this->evaluateBoolean($xmlRoot['read-only'])) {
             $metadata->markReadOnly();
         }
     } else {
         if ($xmlRoot->getName() == 'mapped-superclass') {
             $metadata->setCustomRepositoryClass(isset($xmlRoot['repository-class']) ? (string) $xmlRoot['repository-class'] : null);
             $metadata->isMappedSuperclass = true;
         } else {
             throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
         }
     }
     // Evaluate <entity...> attributes
     $table = array();
     if (isset($xmlRoot['table'])) {
         $table['name'] = (string) $xmlRoot['table'];
     }
     $metadata->setPrimaryTable($table);
     // Evaluate named queries
     if (isset($xmlRoot->{'named-queries'})) {
         foreach ($xmlRoot->{'named-queries'}->{'named-query'} as $namedQueryElement) {
             $metadata->addNamedQuery(array('name' => (string) $namedQueryElement['name'], 'query' => (string) $namedQueryElement['query']));
         }
     }
     // Evaluate native named queries
     if (isset($xmlRoot->{'named-native-queries'})) {
         foreach ($xmlRoot->{'named-native-queries'}->{'named-native-query'} as $nativeQueryElement) {
             $metadata->addNamedNativeQuery(array('name' => isset($nativeQueryElement['name']) ? (string) $nativeQueryElement['name'] : null, 'query' => isset($nativeQueryElement->query) ? (string) $nativeQueryElement->query : null, 'resultClass' => isset($nativeQueryElement['result-class']) ? (string) $nativeQueryElement['result-class'] : null, 'resultSetMapping' => isset($nativeQueryElement['result-set-mapping']) ? (string) $nativeQueryElement['result-set-mapping'] : null));
         }
     }
     // Evaluate sql result set mapping
     if (isset($xmlRoot->{'sql-result-set-mappings'})) {
         foreach ($xmlRoot->{'sql-result-set-mappings'}->{'sql-result-set-mapping'} as $rsmElement) {
             $entities = array();
             $columns = array();
             foreach ($rsmElement as $entityElement) {
                 //<entity-result/>
                 if (isset($entityElement['entity-class'])) {
                     $entityResult = array('fields' => array(), 'entityClass' => (string) $entityElement['entity-class'], 'discriminatorColumn' => isset($entityElement['discriminator-column']) ? (string) $entityElement['discriminator-column'] : null);
                     foreach ($entityElement as $fieldElement) {
                         $entityResult['fields'][] = array('name' => isset($fieldElement['name']) ? (string) $fieldElement['name'] : null, 'column' => isset($fieldElement['column']) ? (string) $fieldElement['column'] : null);
                     }
                     $entities[] = $entityResult;
                 }
                 //<column-result/>
                 if (isset($entityElement['name'])) {
                     $columns[] = array('name' => (string) $entityElement['name']);
                 }
             }
             $metadata->addSqlResultSetMapping(array('name' => (string) $rsmElement['name'], 'entities' => $entities, 'columns' => $columns));
         }
     }
     /* not implemented specially anyway. use table = schema.table
        if (isset($xmlRoot['schema'])) {
            $metadata->table['schema'] = (string)$xmlRoot['schema'];
        }*/
     if (isset($xmlRoot['inheritance-type'])) {
         $inheritanceType = (string) $xmlRoot['inheritance-type'];
         $metadata->setInheritanceType(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceType));
         if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
             // Evaluate <discriminator-column...>
             if (isset($xmlRoot->{'discriminator-column'})) {
                 $discrColumn = $xmlRoot->{'discriminator-column'};
                 $metadata->setDiscriminatorColumn(array('name' => isset($discrColumn['name']) ? (string) $discrColumn['name'] : null, 'type' => isset($discrColumn['type']) ? (string) $discrColumn['type'] : null, 'length' => isset($discrColumn['length']) ? (string) $discrColumn['length'] : null, 'columnDefinition' => isset($discrColumn['column-definition']) ? (string) $discrColumn['column-definition'] : null));
             } else {
                 $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255));
             }
             // Evaluate <discriminator-map...>
             if (isset($xmlRoot->{'discriminator-map'})) {
                 $map = array();
                 foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} as $discrMapElement) {
                     $map[(string) $discrMapElement['value']] = (string) $discrMapElement['class'];
                 }
                 $metadata->setDiscriminatorMap($map);
             }
         }
     }
     // Evaluate <change-tracking-policy...>
     if (isset($xmlRoot['change-tracking-policy'])) {
         $metadata->setChangeTrackingPolicy(constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CHANGETRACKING_' . strtoupper((string) $xmlRoot['change-tracking-policy'])));
     }
     // Evaluate <indexes...>
     if (isset($xmlRoot->indexes)) {
         $metadata->table['indexes'] = array();
         foreach ($xmlRoot->indexes->index as $index) {
             $columns = explode(',', (string) $index['columns']);
             if (isset($index['name'])) {
                 $metadata->table['indexes'][(string) $index['name']] = array('columns' => $columns);
             } else {
//.........这里部分代码省略.........
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:101,代码来源:XmlDriver.php

示例14: getAllClassNames

 /**
  * {@inheritDoc}
  */
 public function getAllClassNames()
 {
     $classes = array();
     if ($this->_paths) {
         $declared = get_declared_classes();
         foreach ((array) $this->_paths as $path) {
             if (!is_dir($path)) {
                 throw MappingException::annotationDriverRequiresConfiguredDirectoryPath();
             }
             $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
             foreach ($iterator as $file) {
                 if (($fileName = $file->getBasename($this->_fileExtension)) == $file->getBasename()) {
                     continue;
                 }
                 require_once $file->getPathName();
             }
         }
         $declared = array_diff(get_declared_classes(), $declared);
         foreach ($declared as $className) {
             if (!$this->isTransient($className)) {
                 $classes[] = $className;
             }
         }
     }
     return $classes;
 }
开发者ID:nvdnkpr,项目名称:symfony-demo,代码行数:29,代码来源:AnnotationDriver.php

示例15: 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


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