当前位置: 首页>>代码示例>>PHP>>正文


PHP Engine::addData方法代码示例

本文整理汇总了PHP中League\Plates\Engine::addData方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine::addData方法的具体用法?PHP Engine::addData怎么用?PHP Engine::addData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\Plates\Engine的用法示例。


在下文中一共展示了Engine::addData方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register

 /**
  * {@inheritdoc}
  */
 public function register(Engine $engine)
 {
     // Add app view data
     $engine->addData(['validation_errors' => [], 'base_js' => [], 'base_css' => []]);
     // Form helpers
     $engine->registerFunction('userPhoto', [$this, 'userPhoto']);
     $engine->registerFunction('requestBody', [$this, 'requestBody']);
     $engine->registerFunction('formFieldError', [$this, 'fieldError']);
     $engine->registerFunction('formInputSelect', [$this, 'inputSelect']);
     $engine->registerFunction('formInputMethod', [$this, 'inputMethod']);
     // Flash Message helpers
     $engine->registerFunction('flashMessages', [$this->flash, 'getMessages']);
     $engine->registerFunction('flashMessage', [$this->flash, 'getMessage']);
     // Register validation helpers
     $engine->registerFunction('validationErrors', function (array $errors = []) use($engine) {
         $engine->addData(['validation_errors' => $errors]);
     });
     // Register view js helpers
     $engine->registerFunction('appendJs', function (array $jsFiles = []) use($engine) {
         $engine->addData(['base_js' => $jsFiles]);
     });
     // Register view css helpers
     $engine->registerFunction('appendCss', function (array $cssFiles = []) use($engine) {
         $engine->addData(['base_css' => $cssFiles]);
     });
     // Pagination Helper
     $engine->registerFunction('viewPages', [$this, 'viewPages']);
 }
开发者ID:aswitahidayat,项目名称:phpindonesia.or.id-membership2,代码行数:31,代码来源:ViewExtension.php

示例2: 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

示例3: setUp

 protected function setUp()
 {
     $plates = new Engine(__DIR__ . '/Resources/views');
     $plates->setFileExtension(null);
     $plates->addData(['foo' => 'bar']);
     $this->engine = new PlatesEngineAdapter($plates);
 }
开发者ID:Symfomany,项目名称:laravelcinema,代码行数:7,代码来源:PlatesEngineAdapterTest.php

示例4: __construct

 /**
  * @param string $tableName Table Name
  * @param string $viewDir User Template directory
  * @throws Exception
  * @throws TableNameException
  * @throws \RedBeanPHP\RedException
  */
 public function __construct($tableName = null, $viewDir = "view")
 {
     R::ext('xdispense', function ($type) {
         return R::getRedBean()->dispense($type);
     });
     if ($tableName != null) {
         $this->setTable($tableName);
     }
     try {
         $this->template = new Engine($viewDir);
     } catch (\LogicException $ex) {
         throw new Exception("The view folder is not existing.");
     }
     // Debug Bar
     $this->debugbar = new StandardDebugBar();
     $debugbarRenderer = $this->debugbar->getJavascriptRenderer(Util::res("vendor/maximebf/debugbar/src/DebugBar/Resources"));
     // Template Default Data
     $this->template->addData(["crud" => $this, "cacheVersion" => $this->cacheVersion, "debugbar" => $this->debugbar, "debugbarRenderer" => $debugbarRenderer]);
     $this->addTheme("adminlte", "vendor/{$this->packageName}/view/theme/AdminLTE");
     $this->setCurrentTheme("adminlte");
     // Enable helper?
     if (defined("ENABLE_CRUD_HELPER") && ENABLE_CRUD_HELPER) {
         //setGlobalCRUD($this);
     }
 }
开发者ID:louislam,项目名称:louislam-crud,代码行数:32,代码来源:LouisCRUD.php

示例5: __construct

 public function __construct()
 {
     $this->setUrl(env('APP_URL'));
     $this->pipe(Middleware::formatNegotiator());
     $this->pipe(Middleware::whoops());
     $this->source(new StaticFiles('build/**/*'))->build(false);
     $this->source(new StaticFiles('source/img/**/*', '/img/**/*'));
     $plates = new Engine('source/templates');
     $plates->addData(['app' => $this]);
     $this->source(new YamlFiles('source/data/*.yml'))->templates($plates);
 }
开发者ID:oscarotero,项目名称:static-boilerplate,代码行数:11,代码来源:Site.php

示例6: register

 public function register(Fol $app)
 {
     $app['templates'] = function ($app) {
         $root = dirname(dirname(__DIR__));
         $templates = new Engine($root . '/templates');
         $icons = new Collection(new MaterialDesignIcons($root . '/assets/icons'));
         $templates->addData(['app' => $app]);
         $templates->registerFunction('icon', function ($name) use($icons) {
             return $icons->get($name);
         });
         return $templates;
     };
 }
开发者ID:oscarotero,项目名称:folk,代码行数:13,代码来源:Templates.php

示例7: addDefaultParam

 /**
  * {@inheritDoc}
  *
  * Proxies to the Plate Engine's `addData()` method.
  *
  * {@inheritDoc}
  */
 public function addDefaultParam($templateName, $param, $value)
 {
     if (!is_string($templateName) || empty($templateName)) {
         throw new Exception\InvalidArgumentException(sprintf('$templateName must be a non-empty string; received %s', is_object($templateName) ? get_class($templateName) : gettype($templateName)));
     }
     if (!is_string($param) || empty($param)) {
         throw new Exception\InvalidArgumentException(sprintf('$param must be a non-empty string; received %s', is_object($param) ? get_class($param) : gettype($param)));
     }
     $params = [$param => $value];
     if ($templateName === self::TEMPLATE_ALL) {
         $templateName = null;
     }
     $this->template->addData($params, $templateName);
 }
开发者ID:weierophinney,项目名称:zend-expressive-platesrenderer,代码行数:21,代码来源:PlatesRenderer.php

示例8: __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

示例9: modifyResponseForTemplateResult

 /**
  * @param ResponseInterface $response
  * @param TemplateResult $templateResult
  * @return ResponseInterface
  */
 private function modifyResponseForTemplateResult(ResponseInterface $response, TemplateResult $templateResult)
 {
     $this->engine->addData(['host' => 'http://' . $this->serverRequest->getServerParams()['HTTP_HOST'] . '/']);
     $stream = \GuzzleHttp\Psr7\stream_for($this->engine->render($templateResult->getTemplate(), $templateResult->getData()));
     return $response->withHeader('Content-Type', 'text/html')->withBody($stream);
 }
开发者ID:creios,项目名称:creiwork-framework,代码行数:11,代码来源:ResponseBuilder.php

示例10: prepareTemplates

 public function prepareTemplates(Engine $template, Injector $injector)
 {
     $template->addData(['pages' => $this->getPages()]);
     $template->setFileExtension('phtml');
     $template->loadExtension(new DirectoryExtension());
 }
开发者ID:graphis,项目名称:cookcountycommunityfund,代码行数:6,代码来源:PlatesConfiguration.php

示例11: add_data

 /**
  * Add data to render.
  *
  * @param  array  $data      Data
  * @param  string $templates Template
  * @return $this
  */
 public function add_data(array $data, $templates = null)
 {
     $this->engine->addData($data, $templates);
     return $this;
 }
开发者ID:bootigniter,项目名称:project,代码行数:12,代码来源:Views.php

示例12: globalData

 /**
  * Share data to all templates.
  *
  * @param array $data
  */
 public function globalData(array $data)
 {
     $this->engine->addData($data);
 }
开发者ID:carbontwelve,项目名称:slim-plates,代码行数:9,代码来源:PlatesRenderer.php

示例13: setup

 /**
  * setup the template engine and sends the parsed content to the engine
  *
  * @uses    \League\Plates\Extension\Asset
  * @uses    \League\Plates\Engine
  * @uses    url
  * @since   1.0
  */
 public function setup()
 {
     $engine = new Engine($this->relativePath . "include" . DS . "styles" . DS . config::init()->style);
     $engine->loadExtension(new Asset($this->relativePath . "include" . DS . "styles" . DS . config::init()->style . DS . "assets", true));
     // add infos for theme
     $this->setStyleParameter("isZipEnabled", false);
     $this->setStyleParameter("showWarnings", false);
     $breadcrumbs = $this->generateBreadcrumbs(url::GET("dir"));
     $this->setStyleParameter("breadcrumbs", $breadcrumbs);
     $this->setStyleParameter("assetspath", common::getRelativePath(getcwd(), dirname(__FILE__)) . DS . "styles" . DS . config::init()->style . DS . "assets");
     $this->setStyleParameter("title", "SimpleDirLister | " . common::fixPaths(implode(DS, array_keys($breadcrumbs))));
     $this->setStyleParameter("path", common::fixPaths(implode(DS, array_keys($breadcrumbs))));
     $this->setStyleParameter("header", config::init()->header ? file::init(config::init()->header)->getFilename() : false);
     $this->setStyleParameter("footer", config::init()->footer ? file::init(config::init()->footer)->getFilename() : false);
     $engine->addFolder('static', $this->getBasePath() . DS . config::init()->headerFooterDir);
     try {
         $files = $this->getRawPaths();
         $files = $this->cleanArray($files);
         if (config::init()->showReadme) {
             $readmeContent = [];
             foreach (config::init()->readme as $readme) {
                 if (isset($files[$readme])) {
                     $c = file_get_contents($files[$readme]["path"]);
                     $ext = pathinfo($files[$readme]["path"], PATHINFO_EXTENSION);
                     if ($ext == "md") {
                         $md = new Parsedown();
                         $readmeContent[] = '<div class="md">' . $md->text($c) . '</div>';
                     } elseif ($ext == "php") {
                         $readmeContent[] = (require $files[$readme]["path"]);
                     } else {
                         $readmeContent[] = $c;
                     }
                     if (config::init()->removeReadme) {
                         unset($files[$readme]);
                     }
                 }
             }
             $this->setStyleParameter("readme", $readmeContent);
         }
     } catch (\Exception $e) {
         $this->setStyleParameter("showWarnings", true);
         $this->setStyleParameter("warnings", [["message" => "dir not found", "type" => "danger"]]);
         $files = [];
     } finally {
         $this->setStyleParameter("files", $files);
     }
     $engine->registerFunction('fileicon', [&$this, "getIconFromSet"]);
     $this->setStyleParameter("search", url::GET("s"));
     $engine->addData($this->styleParameter);
     if (!empty(url::GET("s"))) {
         echo $engine->render("search", $this->styleParameter);
     } else {
         echo $engine->render("index", $this->styleParameter);
     }
 }
开发者ID:profenter,项目名称:simpleDirLister,代码行数:63,代码来源:simpleDirLister.php

示例14: addData

 /**
  * Add preassigned template data.
  *
  * @param  array         $data
  * @param  null|string[] $templates
  * @return \League\Plates\Engine
  */
 public function addData(array $data, $templates = null)
 {
     return $this->plates->addData($data, $templates);
 }
开发者ID:PaulRieger,项目名称:slim-plates,代码行数:11,代码来源:Plates.php


注:本文中的League\Plates\Engine::addData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。