mirror of
https://github.com/typemill/typemill.git
synced 2025-10-16 15:16:14 +02:00
78 lines
1.5 KiB
PHP
78 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Typemill;
|
|
|
|
use \Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
|
|
abstract class Plugin implements EventSubscriberInterface
|
|
{
|
|
|
|
private $app;
|
|
|
|
private $container;
|
|
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param string $name
|
|
* @param Grav $grav
|
|
* @param Config $config
|
|
*/
|
|
public function __construct($container, $app)
|
|
{
|
|
$this->container = $container;
|
|
$this->app = $app;
|
|
}
|
|
|
|
protected function getRoute()
|
|
{
|
|
return $this->container['request']->getUri();
|
|
}
|
|
|
|
protected function getPath()
|
|
{
|
|
return $this->container['request']->getUri()->getPath();
|
|
}
|
|
|
|
protected function getDispatcher()
|
|
{
|
|
return $this->$dispatcher;
|
|
}
|
|
|
|
protected function addTwigGlobal($name, $class)
|
|
{
|
|
$this->container->view->getEnvironment()->addGlobal($name, $class);
|
|
}
|
|
|
|
protected function addTwigFilter($name, $filter)
|
|
{
|
|
$filter = new \Twig_SimpleFilter($name, $filter);
|
|
$this->container->view->getEnvironment()->addFilter($filter);
|
|
}
|
|
|
|
protected function addTwigFunction($name, $function)
|
|
{
|
|
$function = new \Twig_SimpleFunction($name, $function);
|
|
$this->container->view->getEnvironment()->addFunction($function);
|
|
}
|
|
|
|
protected function addJS($JS)
|
|
{
|
|
$this->container->assets->addJS($JS);
|
|
}
|
|
|
|
protected function addInlineJS($JS)
|
|
{
|
|
$this->container->assets->addInlineJS($JS);
|
|
}
|
|
|
|
protected function addCSS($CSS)
|
|
{
|
|
$this->container->assets->addCSS($CSS);
|
|
}
|
|
|
|
protected function addInlineCSS($CSS)
|
|
{
|
|
$this->container->assets->addInlineCSS($CSS);
|
|
}
|
|
} |