- Allows easier integration with DI containers
This commit is contained in:
parent
079d8b058d
commit
423d74aa6c
|
@ -6,6 +6,19 @@ use Picea\Compiler;
|
|||
|
||||
class DefaultRegistrations implements LanguageRegistration
|
||||
{
|
||||
protected array $extensions;
|
||||
|
||||
protected array $syntaxes;
|
||||
|
||||
protected array $controlStructures;
|
||||
|
||||
public function __construct(array $extensions = [], array $syntaxes = [], array $controlStructure = [])
|
||||
{
|
||||
$this->extensions = $extensions;
|
||||
$this->syntaxes = $syntaxes;
|
||||
$this->controlStructures = $controlStructure;
|
||||
}
|
||||
|
||||
public function registerAll(Compiler $compiler) : void
|
||||
{
|
||||
$this->registerSyntax($compiler);
|
||||
|
@ -19,6 +32,10 @@ class DefaultRegistrations implements LanguageRegistration
|
|||
$compiler->registerSyntax(new \Picea\Syntax\CommentToken());
|
||||
$compiler->registerSyntax(new \Picea\Syntax\EchoRawToken());
|
||||
$compiler->registerSyntax(new \Picea\Syntax\EchoSafeToken());
|
||||
|
||||
foreach($this->syntaxes ?? [] as $syntax) {
|
||||
$compiler->registerSyntax($syntax);
|
||||
}
|
||||
}
|
||||
|
||||
public function registerControlStructure(Compiler $compiler) : void
|
||||
|
@ -47,11 +64,19 @@ class DefaultRegistrations implements LanguageRegistration
|
|||
$compiler->registerControlStructure(new \Picea\ControlStructure\SectionToken());
|
||||
$compiler->registerControlStructure(new \Picea\ControlStructure\EndSectionToken());
|
||||
$compiler->registerControlStructure(new \Picea\ControlStructure\ViewToken());
|
||||
|
||||
foreach($this->controlStructures ?? [] as $controlStructure) {
|
||||
$compiler->registerControlStructure($controlStructure);
|
||||
}
|
||||
}
|
||||
|
||||
public function registerExtension(Compiler $compiler) : void
|
||||
{
|
||||
$compiler->registerExtension(new \Picea\Extension\JsonExtension());
|
||||
$compiler->registerExtension(new \Picea\Extension\AssetExtension());
|
||||
|
||||
foreach($this->extensions ?? [] as $extension) {
|
||||
$compiler->registerExtension($extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue