Nette\Reflection\ClassType::getProperty PHP Метод

getProperty() публичный Метод

public getProperty ( $name ) : Property
Результат Property
    public function getProperty($name)
    {
        return new Property($this->getName(), $name);
    }

Usage Example

Пример #1
0
 /**
  * Get BuilderDefinition from entity property
  *
  * @param string $propertyName
  * @param bool $fillValues
  * @return BuilderDefinition|null
  * @throws InvalidStateException
  */
 private function getPropertyRule($propertyName, $fillValues = TRUE)
 {
     $property = $this->entityReflection->getProperty($propertyName);
     $annotations = $this->annotationReader->getPropertyAnnotations($property);
     $rule = new BuilderDefinition($propertyName);
     foreach ($annotations as $annotation) {
         switch (get_class($annotation)) {
             case 'Doctrine\\ORM\\Mapping\\Column':
                 if ($this->getEntityPrimaryKeyName($this->entity) === $propertyName) {
                     $rule->setComponentType(BuilderDefinition::COMPONENT_TYPE_HIDDEN);
                     $rule->setRequired(FALSE);
                 } else {
                     $type = BuilderDefinition::COMPONENT_TYPE_TEXT;
                     $rule->setRequired(!$annotation->nullable);
                     /** @var Column $annotation */
                     if ($annotation->type === 'boolean') {
                         $type = BuilderDefinition::COMPONENT_TYPE_CHECKBOX;
                     }
                     // is numeric?
                     if ($annotation->type === 'integer' || $annotation->type === 'float' || $annotation->type === 'bigint' || $annotation->type === 'decimal' || $annotation->type === 'smallint') {
                         $rule->addValidationRule(Form::NUMERIC, 'This is required in numeric format', TRUE);
                     }
                     $rule->setComponentType($type);
                 }
                 break;
             case 'Doctrine\\ORM\\Mapping\\ManyToOne':
                 /** @var ManyToOne $annotation */
                 $rule->setComponentType(BuilderDefinition::COMPONENT_TYPE_SELECT);
                 if ($fillValues) {
                     $rule->setValues($this->getPossibleValues($annotation->targetEntity));
                 }
                 $rule->setTargetEntity($annotation->targetEntity);
                 $rule->setRequired(TRUE);
                 break;
             case 'Doctrine\\ORM\\Mapping\\ManyToMany':
                 /** @var OneToMany $annotation */
                 $rule->setComponentType(BuilderDefinition::COMPONENT_TYPE_MULTI_SELECT);
                 if ($fillValues) {
                     $rule->setValues($this->getPossibleValues($annotation->targetEntity));
                 }
                 $rule->setRequired(TRUE);
                 $rule->setTargetEntity($annotation->targetEntity);
                 break;
             case 'Doctrine\\ORM\\Mapping\\JoinColumn':
                 /** @var JoinColumn $annotation */
                 $rule->setRequired(!$annotation->nullable);
                 break;
         }
     }
     return $rule->getComponentType() === NULL ? NULL : $rule;
 }
All Usage Examples Of Nette\Reflection\ClassType::getProperty