/** * {@inheritDoc} */ public function registerTagHandler($tagName, $handler) { Assert::stringNotEmpty($tagName); Assert::stringNotEmpty($handler); Assert::classExists($handler); Assert::implementsInterface($handler, StaticMethod::class); if (strpos($tagName, '\\') && $tagName[0] !== '\\') { throw new \InvalidArgumentException('A namespaced tag must have a leading backslash as it must be fully qualified'); } $this->tagHandlerMappings[$tagName] = $handler; }
/** * ContaoRepository constructor. * * @param string $modelClass Model class. */ public function __construct($modelClass) { Assert::classExists($modelClass); Assert::subclassOf($modelClass, 'Model'); $this->modelClass = $modelClass; }
/** * Get a reflection class that has this property. * * @param string $class * @param string $propertyName * * @return \ReflectionClass|null * * @throws \InvalidArgumentException */ protected static function getReflectionClassWithProperty($class, $propertyName) { Assert::string($class, 'First argument to Reflection::getReflectionClassWithProperty must be string. Variable of type "%s" was given.'); Assert::classExists($class, 'Could not find class "%s"'); $refl = new \ReflectionClass($class); if ($refl->hasProperty($propertyName)) { return $refl; } if (false === ($parent = get_parent_class($class))) { // No more parents return; } return self::getReflectionClassWithProperty($parent, $propertyName); }