/** * @param string $controlName * @throws ImageStorageException */ public static function register($controlName = 'addMultiImageUpload') { if (!is_string($controlName)) { throw new ImageStorageException(sprintf('Control name must be a string, %s given', gettype($controlName))); } Object::extensionMethod(Container::class . '::' . $controlName, function ($form, $name, $label = NULL, $namespace = NULL) { $control = new self($label); $control->setNamespace($namespace); return $form[$name] = $control; }); }
public static function buildFromReflection(\ReflectionClass $reflection) { $class = new self($reflection->getShortName()); $class->setNamespace($reflection->getNamespaceName()); $reflectionParentClass = $reflection->getParentClass(); if ($reflectionParentClass) { $class->setParentClassName($reflectionParentClass->getName()); } $class->setAbstract($reflection->isAbstract()); if ($interfaces = $reflection->getInterfaceNames()) { if ($reflectionParentClass) { $parentInterfaces = $reflection->getParentClass()->getInterfaceNames(); $interfaces = array_diff($interfaces, $parentInterfaces); } $class->setInterfaces($interfaces); } foreach ($reflection->getMethods() as $reflectionMethod) { if ($reflectionMethod->getDeclaringClass() == $reflection) { $method = MethodBlock::buildFromReflection($reflectionMethod); $class->addMethod($method); } } foreach ($reflection->getProperties() as $reflectionProperty) { if ($reflectionProperty->getDeclaringClass() == $reflection) { $property = PropertyBlock::buildFromReflection($reflectionProperty); $class->addProperty($property); } } foreach ($reflection->getConstants() as $name => $value) { if (!$reflection->getParentClass()->hasConstant($name)) { $class->addConstant(new ConstantBlock($name, $value)); } } return $class; }