slimphp / PHP-View

A Simple PHP Renderer for Slim 3 & 4 (or any other PSR-7 project)
MIT License
264 stars 60 forks source link

Маленькие улучшения #23

Closed SerginhoLD closed 7 years ago

SerginhoLD commented 8 years ago

1) Заменить $this->templatePath на $this->getTemplatePath() и т.п. Например:

public function __construct($templatePath, array $attributes = [])
{
    $this->setTemplatePath($templatePath);
    $this->setAttributes($attributes);
}

Это очень важно для наследования класса, сейчас это бессмысленно, все равно все переписывать

2) Убрать \InvalidArgumentException("Duplicate template key found") в методе fetch(). Исправить protectedIncludeScope:

protected function protectedIncludeScope ($template, array $data) {
    extract($data, EXTR_SKIP); // fix
    include $template;
}

3) Унаследовать PhpRenderer от \ArrayObject и выкинуть эти функции с $attributes

akrabat commented 8 years ago

Please report any issues in English.

SerginhoLD commented 8 years ago

Как все трудно..

Google translate:

1) Replace the $this->templatePath at $ this->getTemplatePath(), etc. For example:

public function __construct($templatePath, array $attributes = [])
{
     $this->setTemplatePath($templatePath);
     $this->setAttributes($attributes);
}

It is necessary to inherit PhpRenderer class, now it is pointless to have to rewrite all

2) Remove \InvalidArgumentException("Duplicate template key found") in the fetch() method. Correct protectedIncludeScope:

protected function protectedIncludeScope($template, array $data) {
     extract($data, EXTR_SKIP); // fix
     include $template;
}

3) PhpRenderer Inherit from class \ArrayObject and remove features that use the $attributes. (It also uses an interface \ ArrayAccess, https://github.com/slimphp/Twig-View/)