當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Engine::addFolder方法代碼示例

本文整理匯總了PHP中League\Plates\Engine::addFolder方法的典型用法代碼示例。如果您正苦於以下問題:PHP Engine::addFolder方法的具體用法?PHP Engine::addFolder怎麽用?PHP Engine::addFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在League\Plates\Engine的用法示例。


在下文中一共展示了Engine::addFolder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: prepareEngine

 public function prepareEngine(Engine $engine)
 {
     // set file extension
     // $engine->setFileExtension('php');
     // Add folders
     $engine->addFolder('templates', APPPATH . 'templates');
     $engine->addFolder('partials', APPPATH . 'templates/partials');
     $engine->addFolder('staticpages', APPPATH . 'templates/staticpages');
 }
開發者ID:elevenone,項目名稱:sparkle,代碼行數:9,代碼來源:PlatesConfiguration.php

示例2: create

 /**
  * Create view template
  *
  * @return Engine
  */
 public static function create(ServiceContainer $app)
 {
     $view = new Engine($app->config['path']['view'], null);
     // Add folder shortcut (assets::file.js)
     $view->addFolder('assets', $app->config['path']['assets']);
     $view->addFolder('view', $app->config['path']['view']);
     static::initViewCache($view, $app);
     return $view;
 }
開發者ID:odan,項目名稱:molengo,代碼行數:14,代碼來源:ViewFactory.php

示例3: __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));
 }
開發者ID:nikolaposa,項目名稱:devpage,代碼行數:10,代碼來源:ApplicationFactory.php

示例4: addPath

 /**
  * Add a path for template
  *
  * Multiple calls to this method without a namespace will trigger an
  * E_USER_WARNING and act as a no-op. Plates does not handle non-namespaced
  * folders, only the default directory; overwriting the default directory
  * is likely unintended.
  *
  * @param string $path
  * @param string $namespace
  */
 public function addPath($path, $namespace = null)
 {
     if (!$namespace && !$this->template->getDirectory()) {
         $this->template->setDirectory($path);
         return;
     }
     if (!$namespace) {
         trigger_error('Cannot add duplicate un-namespaced path in Plates template adapter', E_USER_WARNING);
         return;
     }
     $this->template->addFolder($namespace, $path, true);
 }
開發者ID:weierophinney,項目名稱:zend-expressive-platesrenderer,代碼行數:23,代碼來源:PlatesRenderer.php

示例5: create

 /**
  * Create instance
  *
  * @return Engine
  */
 public function create(Request $request)
 {
     $engine = new Engine($this->options['view_path'], null);
     // Add folder shortcut (assets::file.js)
     $engine->addFolder('assets', $this->options['assets_path']);
     $engine->addFolder('view', $this->options['view_path']);
     $session = $request->getAttribute(SessionMiddleware::ATTRIBUTE);
     $baseUrl = $request->getAttribute('base_url');
     // Register Asset extension
     $cacheOptions = array('cachepath' => $this->options['cache_path'], 'cachekey' => $session->get('user.locale'), 'baseurl' => $baseUrl, 'minify' => $this->options['minify']);
     $engine->loadExtension(new \Odan\Plates\Extension\AssetCache($cacheOptions));
     return $engine;
 }
開發者ID:odan,項目名稱:psr7-full-stack,代碼行數:18,代碼來源:PlatesMiddleware.php

示例6: register

 public function register()
 {
     $this->container->add('service.http.request', function () {
         return Request::createFromGlobals();
     });
     $this->container->add('service.http.route', function () {
         $route = new Route($this->container);
         foreach ($this->container->get('config')['http']['routes'] as $item) {
             $route->addRoute(strtoupper($item['method']), $item['path'], $item['target']);
         }
         return $route;
     });
     $this->container->add('Symfony\\Component\\HttpFoundation\\Request', function () {
         return $this->container->get('service.http.request');
     });
     $this->container->add('service.view.view', function () {
         $view = new View();
         foreach ($this->container->get('config')['http']['views_path'] as $name => $path) {
             $view->addFolder($name, $path);
         }
         $request = $this->container->get('service.http.request');
         $view->loadExtension(new RequestExtension($request));
         $view->loadExtension(new FlashBagExtension($request->getSession()->getFlashBag()));
         $view->loadExtension(new BaseUrlExtension($request->getBasePath()));
         $assetBaseUrl = $this->container->get('config')['asset_base_url'];
         $view->loadExtension(new AssetUrlExtension($assetBaseUrl));
         if ($this->container->get('service.account.auth')->hasAuthenticatedUser()) {
             $authenticatedUser = $this->container->get('service.account.auth')->getAuthenticatedUser();
             $view->loadExtension(new AuthenticatedUserExtension($authenticatedUser));
         }
         $view->addData(['applicationName' => $this->container->get('config')['application_name']]);
         return $view;
     });
 }
開發者ID:jirro,項目名稱:jirro,代碼行數:34,代碼來源:HttpServiceProvider.php

示例7: 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;
 }
開發者ID:philipsharp,項目名稱:slim-view-plates,代碼行數:21,代碼來源:Plates.php

示例8: __construct

 /**
  * PlatesProvider constructor.
  * @param Engine $plates
  * @param string $root_path
  * @param string $namespace
  */
 public function __construct(Engine $plates, $root_path, $namespace)
 {
     $this->plates = $plates;
     $this->namespace = $namespace;
     if (!$plates->getFolders()->exists($namespace)) {
         $plates->addFolder($namespace, $root_path);
     }
 }
開發者ID:perfumer,項目名稱:framework,代碼行數:14,代碼來源:PlatesProvider.php

示例9: render

 /**
  * Render a string
  *
  * @param string $template The template content to render
  * @param array $locals The variable to use in template
  * @return null|string
  */
 public function render($template, array $locals = array())
 {
     $tmpName = uniqid('plates_tmp_', false);
     $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tmpName;
     if (!is_null($this->plates->getFileExtension())) {
         $tmpPath .= '.' . $this->plates->getFileExtension();
     }
     $isTmpRegister = $this->plates->getFolders()->exists(sys_get_temp_dir());
     if (!$isTmpRegister) {
         $this->plates->addFolder(sys_get_temp_dir(), sys_get_temp_dir());
     }
     file_put_contents($tmpPath, $template);
     $data = $this->plates->render(sys_get_temp_dir() . '::' . $tmpName, $locals);
     unlink($tmpPath);
     if (!$isTmpRegister) {
         $this->plates->getFolders()->remove(sys_get_temp_dir());
     }
     return $data;
 }
開發者ID:phptransformers,項目名稱:plates,代碼行數:26,代碼來源:PlatesTransformer.php

示例10: __invoke

 public function __invoke(array $input)
 {
     $name = 'world';
     if (!empty($input['name'])) {
         $name = $input['name'];
     }
     ////////////////////
     $application = new Application();
     $application_data = $application->is_pjax();
     //print_r( '<pre>' );
     // print_r( $application_data );
     //print_r( '</pre>');
     ////////////////////
     // simple
     // Create new Plates instance
     //		$plates = new Engine(APPPATH.'templates');
     // Render a template
     // $template = $plates->render('partials/profile', ['name' => $name . ' | ' . $data_from_an_other_class]);
     //		$template = $plates->render('partials/profile', ['name' => $name . ' | ' . $application_data]);
     $data = ['friends' => ['mikka', 'makka', 'zorro']];
     //			$friends = [
     //			  ['name', 'zorro'],
     //			];
     ////////////////////
     // using folders
     // Create new Plates instance
     $plates = new Engine(APPPATH . 'templates');
     // Register a Plates extension
     $plates->loadExtension(new Utils());
     // Add folders
     $plates->addFolder('layout', APPPATH . 'templates');
     $plates->addFolder('partials', APPPATH . 'templates/partials');
     $plates->addFolder('static', APPPATH . 'templates/static');
     // assign data to plates
     $plates->addData($data, 'layout');
     // Render
     $template = $plates->render('partials::profile', ['name' => $name]);
     ////////////////////
     $invitation = 'I invite you';
     // return
     return (new Payload())->withStatus(Payload::OK)->withOutput(['hello' => $template, 'invitation' => $invitation]);
 }
開發者ID:elevenone,項目名稱:spark-project-foundation,代碼行數:42,代碼來源:Index.php

示例11: 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;
 }
開發者ID:media32,項目名稱:slim-view-plates,代碼行數:25,代碼來源:Plates.php

示例12: getLoader

 /**
  * Plates paths loader.
  */
 protected function getLoader() : LeagueEngine
 {
     if (!$this->engine) {
         $config = $this->config;
         $this->engine = new LeagueEngine($config['template']['default'] ?? null, $config['engine']['plates']['file_extension'] ?? null);
         if (($paths = $config['template']['paths'] ?? null) !== null) {
             foreach ($paths as $name => $addPaths) {
                 $this->engine->addFolder($name, $addPaths);
             }
         }
     }
     return $this->engine;
 }
開發者ID:narrowspark,項目名稱:framework,代碼行數:16,代碼來源:Plates.php

示例13: addFolder

 /**
  * Add a new template folder for grouping templates under different namespaces.
  *
  * @param string $name      Folder name
  * @param string $directory Folder path
  * @param bool   $fallback  Folder falback
  */
 public function addFolder($name, $directory, $fallback = false)
 {
     $this->engine->addFolder($name, $directory, $fallback);
     return $this->engine;
 }
開發者ID:projek-xyz,項目名稱:ci-common,代碼行數:12,代碼來源:Views.php

示例14: registerTemplateEngine

 /**
  * Register template engine
  *
  * @return $this
  */
 protected function registerTemplateEngine()
 {
     $container = $this->getContainer();
     $this->getContainer()->add(Engine::class, function () use($container) {
         /** @var \Pagewire\Core\Application $app */
         $app = $container->get(ApplicationInterface::class);
         $templates = $app->getConfig('templates', []);
         if (isset($templates['default'])) {
             $default = $templates['default'];
             unset($templates['default']);
         } else {
             $default = reset($templates);
             $defaultKey = key($default);
             unset($templates[$defaultKey]);
         }
         $engine = new Engine($default);
         foreach ($templates as $name => $template) {
             $engine->addFolder($name, $template, false);
         }
         return $engine;
     });
     return $this;
 }
開發者ID:pagewire,項目名稱:core,代碼行數:28,代碼來源:ApplicationProvider.php

示例15: prepareEngine

 public function prepareEngine(Engine $engine)
 {
     $engine->addFolder('my', __DIR__ . '/../templates');
 }
開發者ID:elevenone,項目名稱:spark-plates-test,代碼行數:4,代碼來源:PlatesConfiguration.php


注:本文中的League\Plates\Engine::addFolder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。