Neos\Flow\Reflection\ReflectionService::getAllImplementationClassNamesForInterface PHP 메소드

getAllImplementationClassNamesForInterface() 공개 메소드

Searches for and returns all class names of implementations of the given object type (interface name). If no class implementing the interface was found, an empty array is returned.
public getAllImplementationClassNamesForInterface ( string $interfaceName ) : array
$interfaceName string Name of the interface
리턴 array An array of class names of the default implementation for the object type
    public function getAllImplementationClassNamesForInterface($interfaceName)
    {
        if (!$this->initialized) {
            $this->initialize();
        }
        $interfaceName = $this->cleanClassName($interfaceName);
        if (interface_exists($interfaceName) === false) {
            throw new \InvalidArgumentException('"' . $interfaceName . '" does not exist or is not the name of an interface.', 1238769560);
        }
        $this->loadOrReflectClassIfNecessary($interfaceName);
        return isset($this->classReflectionData[$interfaceName][self::DATA_INTERFACE_IMPLEMENTATIONS]) ? array_keys($this->classReflectionData[$interfaceName][self::DATA_INTERFACE_IMPLEMENTATIONS]) : [];
    }

Usage Example

 /**
  * Adds all validators that extend the AssetValidatorInterface.
  *
  * @return void
  */
 protected function initializeObject()
 {
     $assetValidatorImplementationClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface(AssetValidatorInterface::class);
     foreach ($assetValidatorImplementationClassNames as $assetValidatorImplementationClassName) {
         $this->addValidator($this->objectManager->get($assetValidatorImplementationClassName));
     }
 }
All Usage Examples Of Neos\Flow\Reflection\ReflectionService::getAllImplementationClassNamesForInterface
ReflectionService