本文整理汇总了PHP中League\Plates\Engine::setFileExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine::setFileExtension方法的具体用法?PHP Engine::setFileExtension怎么用?PHP Engine::setFileExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Plates\Engine
的用法示例。
在下文中一共展示了Engine::setFileExtension方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public function getInstance()
{
if (!$this->_engineInstance) {
// Create new Plates engine
$this->_engineInstance = new PlatesEngine($this->getTemplatesDirectory());
if ($this->fileExtension) {
$this->_engineInstance->setFileExtension($this->fileExtension);
}
}
return $this->_engineInstance;
}
示例2: __construct
/**
* The transformer constructor.
*
* Options are:
* - "plates" a \League\Plates\Engine instance
* - "directory" the directory where Plates will search templates
* - "extension" the extension of template files
* if the option "plates" is provided, options "default" and "extension" are ignored.
*
* @param array $options The PlatesTransformer options
*/
public function __construct(array $options = array())
{
if (array_key_exists('plates', $options)) {
$this->plates = $options['plates'];
return;
}
$this->plates = new Engine(getcwd(), null);
if (array_key_exists('directory', $options)) {
$this->plates->setDirectory($options['directory']);
}
if (array_key_exists('extension', $options)) {
$this->plates->setFileExtension($options['extension']);
}
}
示例3: setUp
protected function setUp()
{
$plates = new Engine(__DIR__ . '/Resources/views');
$plates->setFileExtension(null);
$plates->addData(['foo' => 'bar']);
$this->engine = new PlatesEngineAdapter($plates);
}
示例4: getInstance
/**
* Get a Plates engine
*
* @return \League\Plates\Engine
*/
public function getInstance()
{
if (!$this->engineInstance) {
// Create new Plates engine
$this->engineInstance = new \League\Plates\Engine($this->templatesPath ?: $this->getTemplatesDirectory());
if ($this->fileExtension) {
$this->engineInstance->setFileExtension($this->fileExtension);
}
if (count($this->templatesFolders)) {
foreach ($this->templatesFolders as $name => $path) {
$this->engineInstance->addFolder($name, $path);
}
}
}
return $this->engineInstance;
}
示例5: plates
private function plates()
{
$league = new Plates\Engine(APP . 'views');
$league->setFileExtension('tpl');
$league->loadExtension(new Plates\Extension\URI(trim(strtok(str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['REQUEST_URI']), '?'), '/')));
$league->loadExtension(new MY\Plates\Extension());
return $league;
}
示例6: __invoke
public function __invoke(array $config)
{
$theme = $config['theme'];
$templateEngine = new Engine();
$templateEngine->addFolder('app', 'templates');
$templateEngine->addFolder('theme', 'public/themes/' . $theme . '/templates');
$templateEngine->setFileExtension('phtml');
$templateEngine->loadExtensions([new AssetExt('public', true), new ThemeAssetExt('themes/' . $theme . '/assets')]);
return new Application($config, new PlatesTemplateRenderer($templateEngine));
}
示例7: getInstance
/**
* Get an instance of the Plates Engine
*
* @return \League\Plates\Engine
*/
public function getInstance()
{
if (!$this->engineInstance) {
$this->engineInstance = new Engine($this->templatesPath ?: $this->getTemplatesDirectory());
if ($this->fileExtension) {
$this->engineInstance->setFileExtension($this->fileExtension);
}
if (count($this->templatesFolders) > 0) {
foreach ($this->templatesFolders as $name => $path) {
$this->engineInstance->addFolder($name, $path);
}
}
if (count($this->parserExtensions) > 0) {
foreach ($this->parserExtensions as $extension) {
$this->engineInstance->loadExtension($extension);
}
}
}
return $this->engineInstance;
}
示例8: __invoke
/**
* @param ContainerInterface $container
* @return PlatesRenderer
*/
public function __invoke(ContainerInterface $container)
{
$config = $container->has('config') ? $container->get('config') : [];
$config = isset($config['templates']) ? $config['templates'] : [];
// Create the engine instance:
$engine = new PlatesEngine();
// Set file extension
if (isset($config['extension'])) {
$engine->setFileExtension($config['extension']);
}
// Inject engine
$plates = new PlatesRenderer($engine);
// Add template paths
$allPaths = isset($config['paths']) && is_array($config['paths']) ? $config['paths'] : [];
foreach ($allPaths as $namespace => $paths) {
$namespace = is_numeric($namespace) ? null : $namespace;
foreach ((array) $paths as $path) {
$plates->addPath($path, $namespace);
}
}
return $plates;
}
示例9: prepareTemplates
public function prepareTemplates(Engine $template, Injector $injector)
{
$template->addData(['pages' => $this->getPages()]);
$template->setFileExtension('phtml');
$template->loadExtension(new DirectoryExtension());
}
示例10: registerTemplateEngine
protected function registerTemplateEngine()
{
$this->slim->container->singleton('plates.engine', function () {
$engine = new Engine();
$engine->setFileExtension($this->slim->config('controller.template_suffix'))->loadExtension(new Asset(self::getWebDir()))->setDirectory($this->getAppDir() . '/Resources/views');
return $engine;
});
$this->slim->container->singleton('plates.template', function () {
$template = new Template($this->slim->container->get('plates.engine'));
return $template;
});
$this->slim->config('view', new PlatesView($this->slim));
return $this;
}
示例11: setTemplateEngine
/**
* @param Engine $templateEngine
* @Required
*/
public function setTemplateEngine(Engine $templateEngine)
{
$this->templateEngine = $templateEngine;
$this->templateEngine->setFileExtension(null);
}
示例12: setUp
protected function setUp()
{
$engine = new Engine(dirname(__DIR__) . '/Fixtures');
$this->plates = new Template($engine->setFileExtension(null));
$this->engine = new PlatesEngine($this->plates);
$this->template = 'foobar.plates.php';
}