class PropertyMetadata

Hierarchy

Expanded class hierarchy of PropertyMetadata

1 file declares its use of PropertyMetadata
PropertyMetadataTest.php in drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/PropertyMetadata.php, line 16

Namespace

Symfony\Component\Validator\Mapping
View source
class PropertyMetadata extends MemberMetadata {

  /**
   * Constructor.
   *
   * @param string $class The class this property is defined on
   * @param string $name  The name of this property
   *
   * @throws ValidatorException
   */
  public function __construct($class, $name) {
    if (!property_exists($class, $name)) {
      throw new ValidatorException(sprintf('Property %s does not exist in class %s', $name, $class));
    }
    parent::__construct($class, $name, $name);
  }

  /**
   * {@inheritDoc}
   */
  public function getPropertyValue($object) {
    return $this
      ->getReflectionMember($object)
      ->getValue($object);
  }

  /**
   * {@inheritDoc}
   */
  protected function newReflectionMember($objectOrClassName) {
    $class = new \ReflectionClass($objectOrClassName);
    while (!$class
      ->hasProperty($this
      ->getName())) {
      $class = $class
        ->getParentClass();
    }
    $member = new \ReflectionProperty($class
      ->getName(), $this
      ->getName());
    $member
      ->setAccessible(true);
    return $member;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ElementMetadata::$constraints public property
ElementMetadata::$constraintsByGroup public property
ElementMetadata::findConstraints public function Returns the constraints of the given group and global ones (* group).
ElementMetadata::getConstraints public function Returns all constraints of this element.
ElementMetadata::hasConstraints public function Returns whether this element has any constraints.
ElementMetadata::__clone public function Clones this object.
MemberMetadata::$cascaded public property
MemberMetadata::$class public property
MemberMetadata::$collectionCascaded public property
MemberMetadata::$collectionCascadedDeeply public property
MemberMetadata::$name public property
MemberMetadata::$property public property
MemberMetadata::$reflMember private property
MemberMetadata::accept public function Implementation of the Visitor design pattern. Overrides MetadataInterface::accept
MemberMetadata::addConstraint public function Adds a constraint to this element. Overrides ElementMetadata::addConstraint
MemberMetadata::getClassName public function Returns the class this member is defined on Overrides ClassBasedInterface::getClassName
MemberMetadata::getName public function Returns the name of the member
MemberMetadata::getPropertyName public function Returns the name of the property this member belongs to Overrides PropertyMetadataInterface::getPropertyName
MemberMetadata::getReflectionMember public function Returns the Reflection instance of the member
MemberMetadata::isCascaded public function Returns whether objects stored in this member should be validated
MemberMetadata::isCollectionCascaded public function Returns whether arrays or traversable objects stored in this member should be traversed and validated in each entry
MemberMetadata::isCollectionCascadedDeeply public function Returns whether arrays or traversable objects stored in this member should be traversed recursively for inner arrays/traversable objects
MemberMetadata::isPrivate public function Returns whether this member is private
MemberMetadata::isProtected public function Returns whether this member is protected
MemberMetadata::isPublic public function Returns whether this member is public
MemberMetadata::__sleep public function Returns the names of the properties that should be serialized Overrides ElementMetadata::__sleep
PropertyMetadata::getPropertyValue public function Extracts the value of the property from the given container. Overrides PropertyMetadataInterface::getPropertyValue
PropertyMetadata::newReflectionMember protected function Creates a new Reflection instance for the member Overrides MemberMetadata::newReflectionMember
PropertyMetadata::__construct public function Constructor. Overrides MemberMetadata::__construct