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


PHP ClassMetadata::getClassName方法代码示例

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


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

示例1: loadClassMetadata

 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         $this->classes = array();
         $xml = $this->parseFile($this->file);
         foreach ($xml->namespace as $namespace) {
             $this->namespaces[(string) $namespace['prefix']] = trim((string) $namespace);
         }
         foreach ($xml->class as $class) {
             $this->classes[(string) $class['name']] = $class;
         }
     }
     if (isset($this->classes[$metadata->getClassName()])) {
         $xml = $this->classes[$metadata->getClassName()];
         foreach ($this->parseConstraints($xml->constraint) as $constraint) {
             $metadata->addConstraint($constraint);
         }
         foreach ($xml->property as $property) {
             foreach ($this->parseConstraints($property->constraint) as $constraint) {
                 $metadata->addPropertyConstraint((string) $property['name'], $constraint);
             }
         }
         foreach ($xml->getter as $getter) {
             foreach ($this->parseConstraints($getter->constraint) as $constraint) {
                 $metadata->addGetterConstraint((string) $getter['property'], $constraint);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:34,代码来源:XmlFileLoader.php

示例2: loadClassMetadata

 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         $this->classes = Yaml::load($this->file);
     }
     // TODO validation
     if (isset($this->classes[$metadata->getClassName()])) {
         $yaml = $this->classes[$metadata->getClassName()];
         if (isset($yaml['constraints'])) {
             foreach ($this->parseNodes($yaml['constraints']) as $constraint) {
                 $metadata->addConstraint($constraint);
             }
         }
         if (isset($yaml['properties'])) {
             foreach ($yaml['properties'] as $property => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addPropertyConstraint($property, $constraint);
                 }
             }
         }
         if (isset($yaml['getters'])) {
             foreach ($yaml['getters'] as $getter => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addGetterConstraint($getter, $constraint);
                 }
             }
         }
         return true;
     }
     return false;
 }
开发者ID:janmarek,项目名称:Neuron,代码行数:34,代码来源:YamlFileLoader.php

示例3: loadClassMetadata

 /**
  * {@inheritdoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         if (null === $this->yamlParser) {
             $this->yamlParser = new YamlParser();
         }
         // This method may throw an exception. Do not modify the class'
         // state before it completes
         if (false === ($classes = $this->parseFile($this->file))) {
             return false;
         }
         $this->classes = $classes;
         if (isset($this->classes['namespaces'])) {
             foreach ($this->classes['namespaces'] as $alias => $namespace) {
                 $this->addNamespaceAlias($alias, $namespace);
             }
             unset($this->classes['namespaces']);
         }
     }
     if (isset($this->classes[$metadata->getClassName()])) {
         $classDescription = $this->classes[$metadata->getClassName()];
         $this->loadClassMetadataFromYaml($metadata, $classDescription);
         return true;
     }
     return false;
 }
开发者ID:mm999,项目名称:EduSoho,代码行数:29,代码来源:YamlFileLoader.php

示例4: loadClassMetadata

 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         $this->classes = Yaml::parse($this->file);
         // empty file
         if (null === $this->classes) {
             return false;
         }
         // not an array
         if (!is_array($this->classes)) {
             throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file));
         }
         if (isset($this->classes['namespaces'])) {
             foreach ($this->classes['namespaces'] as $alias => $namespace) {
                 $this->addNamespaceAlias($alias, $namespace);
             }
             unset($this->classes['namespaces']);
         }
     }
     // TODO validation
     if (isset($this->classes[$metadata->getClassName()])) {
         $yaml = $this->classes[$metadata->getClassName()];
         if (isset($yaml['group_sequence_provider'])) {
             $metadata->setGroupSequenceProvider((bool) $yaml['group_sequence_provider']);
         }
         if (isset($yaml['group_sequence'])) {
             $metadata->setGroupSequence($yaml['group_sequence']);
         }
         if (isset($yaml['constraints']) && is_array($yaml['constraints'])) {
             foreach ($this->parseNodes($yaml['constraints']) as $constraint) {
                 $metadata->addConstraint($constraint);
             }
         }
         if (isset($yaml['properties']) && is_array($yaml['properties'])) {
             foreach ($yaml['properties'] as $property => $constraints) {
                 if (null !== $constraints) {
                     foreach ($this->parseNodes($constraints) as $constraint) {
                         $metadata->addPropertyConstraint($property, $constraint);
                     }
                 }
             }
         }
         if (isset($yaml['getters']) && is_array($yaml['getters'])) {
             foreach ($yaml['getters'] as $getter => $constraints) {
                 if (null !== $constraints) {
                     foreach ($this->parseNodes($constraints) as $constraint) {
                         $metadata->addGetterConstraint($getter, $constraint);
                     }
                 }
             }
         }
         return true;
     }
     return false;
 }
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:58,代码来源:YamlFileLoader.php

示例5: loadClassMetadata

 /**
  * {@inheritdoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         $this->loadClassesFromXml();
     }
     if (isset($this->classes[$metadata->getClassName()])) {
         $classDescription = $this->classes[$metadata->getClassName()];
         $this->loadClassMetadataFromXml($metadata, $classDescription);
         return true;
     }
     return false;
 }
开发者ID:ayoah,项目名称:symfony,代码行数:15,代码来源:XmlFileLoader.php

示例6: loadClassMetadata

 /**
  * {@inheritdoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         // This method may throw an exception. Do not modify the class'
         // state before it completes
         $xml = $this->parseFile($this->file);
         $this->classes = array();
         foreach ($xml->namespace as $namespace) {
             $this->addNamespaceAlias((string) $namespace['prefix'], trim((string) $namespace));
         }
         foreach ($xml->class as $class) {
             $this->classes[(string) $class['name']] = $class;
         }
     }
     if (isset($this->classes[$metadata->getClassName()])) {
         $classDescription = $this->classes[$metadata->getClassName()];
         $this->loadClassMetadataFromXml($metadata, $classDescription);
         return true;
     }
     return false;
 }
开发者ID:mkemiche,项目名称:Annuaire,代码行数:24,代码来源:XmlFileLoader.php

示例7: loadClassMetadata

 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         $this->classes = Yaml::load($this->file);
     }
     // empty file
     if (null === $this->classes) {
         return false;
     }
     // not an array
     if (!is_array($this->classes)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file));
     }
     // TODO validation
     if (isset($this->classes[$metadata->getClassName()])) {
         $yaml = $this->classes[$metadata->getClassName()];
         if (isset($yaml['constraints'])) {
             foreach ($this->parseNodes($yaml['constraints']) as $constraint) {
                 $metadata->addConstraint($constraint);
             }
         }
         if (isset($yaml['properties'])) {
             foreach ($yaml['properties'] as $property => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addPropertyConstraint($property, $constraint);
                 }
             }
         }
         if (isset($yaml['getters'])) {
             foreach ($yaml['getters'] as $getter => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addGetterConstraint($getter, $constraint);
                 }
             }
         }
         return true;
     }
     return false;
 }
开发者ID:notbrain,项目名称:symfony,代码行数:42,代码来源:YamlFileLoader.php

示例8: walkClass

 public function walkClass(ClassMetadata $metadata, $object, $group, $propertyPath)
 {
     $this->context->setCurrentClass($metadata->getClassName());
     foreach ($metadata->findConstraints($group) as $constraint) {
         $this->walkConstraint($constraint, $object, $group, $propertyPath);
     }
     if ($object !== null) {
         foreach ($metadata->getConstrainedProperties() as $property) {
             $localPropertyPath = empty($propertyPath) ? $property : $propertyPath . '.' . $property;
             $this->walkProperty($metadata, $property, $object, $group, $localPropertyPath);
         }
     }
 }
开发者ID:netixpro,项目名称:symfony,代码行数:13,代码来源:GraphWalker.php

示例9: loadClassMetadata

 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         $this->classes = array();
         $xml = $this->parseFile($this->file);
         foreach ($xml->namespace as $namespace) {
             $this->addNamespaceAlias((string) $namespace['prefix'], trim((string) $namespace));
         }
         foreach ($xml->class as $class) {
             $this->classes[(string) $class['name']] = $class;
         }
     }
     if (isset($this->classes[$metadata->getClassName()])) {
         $xml = $this->classes[$metadata->getClassName()];
         foreach ($xml->{'group-sequence-provider'} as $provider) {
             $metadata->setGroupSequenceProvider(true);
         }
         foreach ($xml->{'group-sequence'} as $groupSequence) {
             if (count($groupSequence->value) > 0) {
                 $metadata->setGroupSequence($this->parseValues($groupSequence[0]->value));
             }
         }
         foreach ($this->parseConstraints($xml->constraint) as $constraint) {
             $metadata->addConstraint($constraint);
         }
         foreach ($xml->property as $property) {
             foreach ($this->parseConstraints($property->constraint) as $constraint) {
                 $metadata->addPropertyConstraint((string) $property['name'], $constraint);
             }
         }
         foreach ($xml->getter as $getter) {
             foreach ($this->parseConstraints($getter->constraint) as $constraint) {
                 $metadata->addGetterConstraint((string) $getter['property'], $constraint);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:42,代码来源:XmlFileLoader.php

示例10: walkObject

 /**
  * Initialize validation on the given object using the given metadata
  * instance and validation group.
  *
  * @param ClassMetadata $metadata
  * @param object        $object       The object to validate
  * @param string        $group        The validator group to use for validation
  * @param string        $propertyPath
  */
 public function walkObject(ClassMetadata $metadata, $object, $group, $propertyPath)
 {
     $this->context->setCurrentClass($metadata->getClassName());
     if ($group === Constraint::DEFAULT_GROUP && $metadata->hasGroupSequence()) {
         $groups = $metadata->getGroupSequence();
         foreach ($groups as $group) {
             $this->walkObjectForGroup($metadata, $object, $group, $propertyPath, Constraint::DEFAULT_GROUP);
             if (count($this->getViolations()) > 0) {
                 break;
             }
         }
     } else {
         $this->walkObjectForGroup($metadata, $object, $group, $propertyPath);
     }
 }
开发者ID:renegare,项目名称:symfony,代码行数:24,代码来源:GraphWalker.php

示例11: walkObject

 /**
  * Initialize validation on the given object using the given metadata
  * instance and validation group.
  *
  * @param ClassMetadata $metadata
  * @param object        $object       The object to validate
  * @param string        $group        The validator group to use for validation
  * @param string        $propertyPath
  */
 public function walkObject(ClassMetadata $metadata, $object, $group, $propertyPath)
 {
     foreach ($this->validatorInitializers as $initializer) {
         if (!$initializer instanceof ObjectInitializerInterface) {
             throw new \LogicException('Validator initializers must implement ObjectInitializerInterface.');
         }
         $initializer->initialize($object);
     }
     $this->context->setCurrentClass($metadata->getClassName());
     if ($group === Constraint::DEFAULT_GROUP && $metadata->hasGroupSequence()) {
         $groups = $metadata->getGroupSequence();
         foreach ($groups as $group) {
             $this->walkObjectForGroup($metadata, $object, $group, $propertyPath, Constraint::DEFAULT_GROUP);
             if (count($this->getViolations()) > 0) {
                 break;
             }
         }
     } else {
         $this->walkObjectForGroup($metadata, $object, $group, $propertyPath);
     }
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:30,代码来源:GraphWalker.php

示例12: loadClassMetadata

 /**
  * {@inheritdoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     $className = $metadata->getClassName();
     if (empty($this->constraintsMapping) || !$this->formConfigProvider->hasConfig($className)) {
         return false;
     }
     $formConfigs = $this->formConfigProvider->getConfigs($className);
     foreach ($formConfigs as $formConfig) {
         if (!$formConfig->is('is_enabled')) {
             continue;
         }
         /** @var FieldConfigId $fieldConfigId */
         $fieldConfigId = $formConfig->getId();
         $fieldName = $fieldConfigId->getFieldName();
         if (!$this->isApplicable($className, $fieldName)) {
             continue;
         }
         $constraints = $this->getConstraintsByFieldType($fieldConfigId->getFieldType());
         foreach ($constraints as $constraint) {
             $metadata->addPropertyConstraint($fieldName, $constraint);
         }
     }
     return true;
 }
开发者ID:Maksold,项目名称:platform,代码行数:27,代码来源:ExtendFieldValidationLoader.php

示例13: addMetadata

 public function addMetadata(ClassMetadata $metadata)
 {
     $this->metadatas[$metadata->getClassName()] = $metadata;
 }
开发者ID:netz98,项目名称:n98-magerun,代码行数:4,代码来源:FakeMetadataFactory.php

示例14: walkObjectForGroup

 protected function walkObjectForGroup(ClassMetadata $metadata, $object, $group, $propertyPath, $propagatedGroup = null)
 {
     $hash = spl_object_hash($object);
     // Exit, if the object is already validated for the current group
     if (isset($this->validatedObjects[$hash][$group])) {
         return;
     }
     // Remember validating this object before starting and possibly
     // traversing the object graph
     $this->validatedObjects[$hash][$group] = true;
     $currentClass = $metadata->getClassName();
     foreach ($metadata->findConstraints($group) as $constraint) {
         $this->walkConstraint($constraint, $object, $group, $propertyPath, $currentClass);
     }
     if (null !== $object) {
         $pathPrefix = empty($propertyPath) ? '' : $propertyPath . '.';
         foreach ($metadata->getConstrainedProperties() as $property) {
             $this->walkProperty($metadata, $property, $object, $group, $pathPrefix . $property, $propagatedGroup);
         }
     }
 }
开发者ID:nashadalam,项目名称:symfony,代码行数:21,代码来源:GraphWalker.php

示例15: write

 public function write(ClassMetadata $metadata)
 {
     $this->cache[$metadata->getClassName()] = $metadata;
 }
开发者ID:janmarek,项目名称:Neuron,代码行数:4,代码来源:ValidatorCache.php


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