Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. StaticMethodLoader.php

function StaticMethodLoader::loadClassMetadata

Overrides LoaderInterface::loadClassMetadata

File

vendor/symfony/validator/Mapping/Loader/StaticMethodLoader.php, line 34

Class

StaticMethodLoader
Loads validation metadata by calling a static method on the loaded class.

Namespace

Symfony\Component\Validator\Mapping\Loader

Code

public function loadClassMetadata(ClassMetadata $metadata) : bool {
    
    /** @var \ReflectionClass $reflClass */
    $reflClass = $metadata->getReflectionClass();
    if (!$reflClass->isInterface() && $reflClass->hasMethod($this->methodName)) {
        $reflMethod = $reflClass->getMethod($this->methodName);
        if ($reflMethod->isAbstract()) {
            return false;
        }
        if (!$reflMethod->isStatic()) {
            throw new MappingException(\sprintf('The method "%s::%s()" should be static.', $reflClass->name, $this->methodName));
        }
        if ($reflMethod->getDeclaringClass()->name != $reflClass->name) {
            return false;
        }
        $reflMethod->invoke(null, $metadata);
        return true;
    }
    return false;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal