Skip to content

Commit

Permalink
Правки документации
Browse files Browse the repository at this point in the history
  • Loading branch information
Elnadrion committed May 8, 2024
1 parent 7e23aac commit 5887afb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
18 changes: 1 addition & 17 deletions docs/extend.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@
В событие передается объект `Twig\Environment`, с которым можно сделать определенные манипуляции.
Пример обработчика события, который зарегистрирует свое расширение:

```php
use Bitrix\Main\EventResult;
use Twig\Environment;

AddEventHandler('', 'onAfterTwigTemplateEngineInited', ['EventClass', 'addTwigExtension']);

class EventClass
{
public static function addTwigExtension(Environment $engine): EventResult
{
$engine->addExtension(new MySuperDuperExtension());
return new EventResult(EventResult::SUCCESS, [$engine];
}
}
```
Пример на D7:
```php
use Bitrix\Main\Event;
use Bitrix\Main\EventResult;
Expand All @@ -41,4 +25,4 @@ class EventClass
}
```

Здесь класс MySuperDuperExtension должен быть наследником класса `Twig\Extension\AbstractExtension` или имплементацией интерфейса `Twig\Extension\GlobalsInterface`.
Здесь класс MySuperDuperExtension должен быть наследником класса `Twig\Extension\AbstractExtension` или имплементацией интерфейса `Twig\Extension\GlobalsInterface`.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ composer require elnadrion/tools.twig
## Требования

* Битрикс: >=20.5.393
* PHP: >=7.2.5
* PHP: >=8.1
* mbstring.func_overload: 0

## Документация
Expand Down

0 comments on commit 5887afb

Please sign in to comment.