class GetterMetadata

Hierarchy

Expanded class hierarchy of GetterMetadata

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

File

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

Namespace

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

  /**
   * Constructor.
   *
   * @param string $class    The class the getter is defined on
   * @param string $property The property which the getter returns
   *
   * @throws ValidatorException
   */
  public function __construct($class, $property) {
    $getMethod = 'get' . ucfirst($property);
    $isMethod = 'is' . ucfirst($property);
    if (method_exists($class, $getMethod)) {
      $method = $getMethod;
    }
    elseif (method_exists($class, $isMethod)) {
      $method = $isMethod;
    }
    else {
      throw new ValidatorException(sprintf('Neither method %s nor %s exists in class %s', $getMethod, $isMethod, $class));
    }
    parent::__construct($class, $method, $property);
  }

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

  /**
   * {@inheritDoc}
   */
  protected function newReflectionMember($objectOrClassName) {
    return new \ReflectionMethod($objectOrClassName, $this
      ->getName());
  }

}

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.
GetterMetadata::getPropertyValue public function Extracts the value of the property from the given container. Overrides PropertyMetadataInterface::getPropertyValue
GetterMetadata::newReflectionMember protected function Creates a new Reflection instance for the member Overrides MemberMetadata::newReflectionMember
GetterMetadata::__construct public function Constructor. Overrides MemberMetadata::__construct
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