-
Notifications
You must be signed in to change notification settings - Fork 39
Trait Helper
Anton edited this page May 15, 2015
·
8 revisions
Реализация поддержка Helperов для класса, есть наверное и для этого патерн, но я его не знаю, а по факту это отдельные методы в отдельных файлах
Код класса:
namespace Application;
/**
* @method void foo(string $text)
*/
class My {
use Helper;
public function __construct()
{
// initial default helper path
$this->addHelperPath(dirname(__FILE__) . '/Helper/');
}
}
Код помощника в файле /Helper/Foo.php
return function ($text) {
print($text);
}
Использование:
$my = new My();
$my->foo('Hello!'); // => Hello!
При добавление помощников в репозиторий, следует описать метод в doccomment'ах расширяемого файла, что позволит использовать автодополнение в IDE.
Acl
Application
Auth
Cache
Common
— Exception
— Collection
— Container
— Helper
— Options
— Singleton
Config
Controller
— Data
— Mapper
—— Crud
—— Rest
— Reflection
Crud
— Crud Table
Db
— Row
— Table
— Relations
— Query
Debug
EventManager
Grid
Http
Layout
Logger
Mailer
Messages
Nil
Proxy
Registry
Request
Response
Router
Session
Translator
Validator
View