本文整理汇总了PHP中Twig_Environment::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Environment::__construct方法的具体用法?PHP Twig_Environment::__construct怎么用?PHP Twig_Environment::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Environment
的用法示例。
在下文中一共展示了Twig_Environment::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(ContainerInterface $container, \Twig_LoaderInterface $loader = null, $options = array())
{
parent::__construct($loader, $options);
foreach ($container->findAnnotatedServiceIds('twig.extension') as $id => $attributes) {
$this->addExtension($container->get($id));
}
}
示例2: __construct
public function __construct(Zwig_View $view, Twig_LoaderInterface $loader = null, $options = array(), Twig_LexerInterface $lexer = null, Twig_ParserInterface $parser = null, Twig_CompilerInterface $compiler = null)
{
$parser = $parser !== null ? $parser : new Zwig_Parser();
parent::__construct($loader, $options, $lexer, $parser, $compiler);
$this->addExtension(new Zwig_Extension());
$this->view = $view;
}
示例3: __construct
/**
* Constructs a TwigEnvironment object and stores cache and storage
* internally.
*/
public function __construct(\Twig_LoaderInterface $loader = NULL, $options = array(), ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler)
{
// @todo Pass as arguments from the DIC.
$this->cache_object = \Drupal::cache();
// Ensure that twig.engine is loaded, given that it is needed to render a
// template because functions like twig_drupal_escape_filter are called.
require_once DRUPAL_ROOT . '/core/themes/engines/twig/twig.engine';
// Set twig path namespace for themes and modules.
$namespaces = array();
foreach ($module_handler->getModuleList() as $name => $extension) {
$namespaces[$name] = $extension->getPath();
}
foreach ($theme_handler->listInfo() as $name => $extension) {
$namespaces[$name] = $extension->getPath();
}
foreach ($namespaces as $name => $path) {
$templatesDirectory = $path . '/templates';
if (file_exists($templatesDirectory)) {
$loader->addPath($templatesDirectory, $name);
}
}
$this->templateClasses = array();
$this->stringLoader = new \Twig_Loader_String();
parent::__construct($loader, $options);
}
示例4: __construct
public function __construct($config, $app, $translator_service, $csrf_provider_service = null)
{
$this->translator_service = $translator_service;
$this->csrf_provider_service = $csrf_provider_service;
$this->app = $app;
$this->context_transformers = isset($config['context_transformers']) && is_array($config['context_transformers']) ? $config['context_transformers'] : array();
$cache_disabled = isset($config['debug']) ? $config['debug'] : false;
$cache_path = isset($config['cache_path']) ? $config['cache_path'] : null;
$paths = isset($config['paths']) ? $config['paths'] : array();
if (!$cache_disabled && !file_exists($cache_path)) {
mkdir($cache_path, 0777, true);
}
$_config = array();
if (!$cache_disabled && file_exists($cache_path)) {
$_config['cache'] = $config['cache_path'];
}
$loader = new \Twig_Loader_Filesystem($paths);
parent::__construct($loader, $_config);
// setup forms if form service is available in the app
$this->initialiseExtensions($config);
$this->addGlobal('app', $app);
$this->addExtension(new TwigCoreExtension());
if (class_exists('Symfony\\Bridge\\Twig\\Extension\\RoutingExtension')) {
if (isset($app['url_generator'])) {
$this->addExtension(new RoutingExtension($app['url_generator']));
}
}
// setup filters defined in config
if (isset($config['filters'])) {
foreach ($config['filters'] as $name => $filter_config) {
$filter = $filter_config['function'];
if (!is_string($filter)) {
try {
$function = Utils::getClosure($filter);
} catch (InvalidClassMethodException $e) {
// noop: treat as native php function
}
}
$options = isset($function_config['options']) ? $function_config['options'] : array();
$filter = new \Twig_SimpleFilter($name, $filter, $options);
$this->addFilter($filter);
}
}
// setup functions defined in config
if (isset($config['functions'])) {
foreach ($config['functions'] as $name => $function_config) {
$function = $function_config['function'];
if (!is_string($function)) {
try {
$function = Utils::getClosure($function);
} catch (InvalidClassMethodException $e) {
// noop: treat as native php function
}
}
$options = isset($function_config['options']) ? $function_config['options'] : array();
$function = new \Twig_SimpleFunction($name, $function, $options);
$this->addFunction($function);
}
}
}
示例5: __construct
/**
* @param Container $c
* @param \Twig_LoaderInterface $twig_loader
*/
public function __construct(Container $c, \Twig_LoaderInterface $twig_loader = null)
{
if (empty($twig_loader)) {
$twig_loader = new \Twig_Loader_Filesystem($c['template_params']['paths']);
}
parent::__construct($twig_loader, $c['template_params']);
$this->setConfig($c);
}
示例6: __construct
/**
* Constructor.
*
* @param Twig_LoaderInterface $loader A Twig_LoaderInterface instance
* @param array $options An array of options
*/
public function __construct(\Twig_LoaderInterface $loader = null, $options = [])
{
parent::__construct($loader, $options);
$this->shortcodeCallbacks = [];
$this->shortcodeFilterCallbacks = [];
// Overwrite internal staging class
$this->staging = new Staging();
}
示例7: __construct
public function __construct(\Twig_LoaderInterface $loader, BaseReport $report, ReportTemplatingHelper $templatingHelper, $options = array())
{
parent::__construct($loader, $options);
$this->report = $report;
$this->extensionManager = new RenderEngineExtensionManager($templatingHelper, $report);
$this->templatingHelper = $templatingHelper;
$this->registerExtensions();
}
示例8: __construct
/**
* {@inheritDoc}
*/
public function __construct(Twig_LoaderInterface $loader = null, $options = array())
{
parent::__construct($loader, $options);
$this->addExtension(new StubbedCore());
$this->initExtensions();
$broker = new StubbedTokenParserBroker();
$this->parsers->addTokenParserBroker($broker);
}
示例9: __construct
public function __construct(\Twig_LoaderInterface $loader = null, $options = [])
{
if (DEBUG) {
$options = array_merge($options, ['debug' => true]);
}
parent::__construct($loader, $options);
$this->addExtension(new Twig_Extension_Debug());
$this->helpers = new ViewHelpers();
}
示例10: __construct
/**
* Constructor
*
* @param \src\config\config $src_config The src configuration
* @param \src\path_helper $path_helper src path helper
* @param \src\extension\manager $extension_manager src extension manager
* @param \Twig_LoaderInterface $loader Twig loader interface
* @param array $options Array of options to pass to Twig
*/
public function __construct($src_config, \src\path_helper $path_helper, \src\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array())
{
$this->src_config = $src_config;
$this->src_path_helper = $path_helper;
$this->extension_manager = $extension_manager;
$this->src_root_path = $this->src_path_helper->get_src_root_path();
$this->web_root_path = $this->src_path_helper->get_web_root_path();
return parent::__construct($loader, $options);
}
示例11: __construct
/**
* {@inheritdoc}
*/
public function __construct(Twig_LoaderInterface $loader, array $options = array())
{
parent::__construct($loader, $options);
if (isset($options['sf_context']) && $options['sf_context'] instanceof sfContext) {
$this->context = $options['sf_context'];
} else {
$this->context = sfContext::getInstance();
}
}
示例12: __construct
public function __construct()
{
parent::__construct(new Kwf_View_Twig_FilesystemLoader('.'), array('cache' => 'cache/twig', 'auto_reload' => false));
$this->addFilter(new Twig_SimpleFilter('date', array('Kwf_Component_Renderer_Twig_Environment', 'date'), array('needs_context' => true)));
$this->addFilter(new Twig_SimpleFilter('dateTime', array('Kwf_Component_Renderer_Twig_Environment', 'dateTime'), array('needs_context' => true)));
$this->addFilter(new Twig_SimpleFilter('money', array('Kwf_Component_Renderer_Twig_Environment', 'money'), array('needs_context' => true)));
$this->addFilter(new Twig_SimpleFilter('mailEncodeText', array('Kwf_Component_Renderer_Twig_Environment', 'mailEncodeText')));
$this->addFilter(new Twig_SimpleFilter('mailLink', array('Kwf_Component_Renderer_Twig_Environment', 'mailLink')));
$this->addFilter(new Twig_SimpleFilter('hiddenOptions', array('Kwf_Component_Renderer_Twig_Environment', 'hiddenOptions')));
}
示例13: __construct
public function __construct(Twig_LoaderInterface $loader = NULL, $options = array())
{
$this->fileExtension = twig_extension();
$options = array_merge(array('autorender' => TRUE), $options);
// Auto render means, overrule default class
if ($options['autorender']) {
$this->autoRender = TRUE;
}
parent::__construct($loader, $options);
}
示例14: __construct
/**
* Twig engine constructor
*/
public function __construct()
{
$primerLoader = new Loader();
// Setup the loader to look from the base directory
$fileSystemLoader = new \Twig_Loader_Filesystem([Primer::$PATTERN_PATH, Primer::$VIEW_PATH, Primer::$BASE_PATH]);
$loader = new \Twig_Loader_Chain([$fileSystemLoader, $primerLoader]);
// Create the engine with the correct cache path and set it to
// invalidate the cache when a template changes
parent::__construct($loader, array('cache' => Primer::$CACHE_PATH, 'auto_reload' => true));
}
示例15: __construct
/**
* @param \Twig_LoaderInterface $loader
* @param array $options
* @param VariablesProvider $variablesProvider
* @param Cache $cache
* @param $cacheKey
* @param \Twig_Extension_Sandbox $sandbox
* @param TranslatorInterface $translator
*/
public function __construct(\Twig_LoaderInterface $loader, $options, VariablesProvider $variablesProvider, Cache $cache, $cacheKey, \Twig_Extension_Sandbox $sandbox, TranslatorInterface $translator)
{
parent::__construct($loader, $options);
$this->variablesProvider = $variablesProvider;
$this->sandBoxConfigCache = $cache;
$this->cacheKey = $cacheKey;
$this->addExtension($sandbox);
$this->configureSandbox();
$this->translator = $translator;
}