ApiGen\Templating\TemplateFactory::createForReflection PHP Méthode

createForReflection() public méthode

public createForReflection ( ReflectionElement $element ) : ApiGen\Templating\Template
$element ReflectionElement
Résultat ApiGen\Templating\Template
    public function createForReflection($element)
    {
        $template = $this->buildTemplate();
        if ($element instanceof ClassReflectionInterface) {
            $template->setFile($this->templateNavigator->getTemplatePath('class'));
            $template->setSavePath($this->templateNavigator->getTemplatePathForClass($element));
        } elseif ($element instanceof ConstantReflectionInterface) {
            $template->setFile($this->templateNavigator->getTemplatePath('constant'));
            $template->setSavePath($this->templateNavigator->getTemplatePathForConstant($element));
        } elseif ($element instanceof FunctionReflectionInterface) {
            $template->setFile($this->templateNavigator->getTemplatePath('function'));
            $template->setSavePath($this->templateNavigator->getTemplatePathForFunction($element));
        }
        return $template;
    }

Usage Example

 public function generate()
 {
     foreach ($this->elementStorage->getFunctions() as $name => $reflectionFunction) {
         $template = $this->templateFactory->createForReflection($reflectionFunction);
         $template = $this->loadTemplateWithParameters($template, $reflectionFunction);
         $template->save();
         $this->onGenerateProgress();
     }
 }