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


PHP Zone::get方法代码示例

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


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

示例1: getGlobals

 public function getGlobals()
 {
     /** @var \Bolt\Config $config */
     $config = $this->app['config'];
     $configVal = $this->safe ? null : $config;
     /** @var \Bolt\Users $users */
     $users = $this->app['users'];
     /** @var \Bolt\Configuration\ResourceManager $resources */
     $resources = $this->app['resources'];
     $zone = null;
     /** @var RequestStack $requestStack */
     $requestStack = $this->app['request_stack'];
     if ($request = $requestStack->getCurrentRequest()) {
         $zone = Zone::get($request);
     }
     // User calls can cause exceptions that block the exception handler
     try {
         /** @deprecated Deprecated since 3.0, to be removed in 4.0. */
         $usersVal = $this->safe ? null : $users->getUsers();
         $usersCur = $users->getCurrentUser();
     } catch (\Exception $e) {
         $usersVal = null;
         $usersCur = null;
     }
     // Structured to allow PHPStorm's SymfonyPlugin to provide code completion
     return ['bolt_name' => $this->app['bolt_name'], 'bolt_version' => $this->app['bolt_version'], 'frontend' => $zone === Zone::FRONTEND, 'backend' => $zone === Zone::BACKEND, 'async' => $zone === Zone::ASYNC, 'paths' => $resources->getPaths(), 'theme' => $config->get('theme'), 'user' => $usersCur, 'users' => $usersVal, 'config' => $configVal];
 }
开发者ID:uk61,项目名称:bolt,代码行数:27,代码来源:TwigExtension.php

示例2: setZone

 /**
  * Sets the request's zone if needed and returns it.
  *
  * @param Request $request
  *
  * @return string
  */
 public function setZone(Request $request)
 {
     if ($zone = Zone::get($request)) {
         return $zone;
     }
     $zone = $this->determineZone($request);
     Zone::set($request, $zone);
     return $zone;
 }
开发者ID:nectd,项目名称:nectd-web,代码行数:16,代码来源:ZoneGuesser.php

示例3: testControllerZone

 /**
  * @covers \Bolt\Controller\Zone::get
  * @covers \Bolt\Controller\Zone::isBackend
  */
 public function testControllerZone()
 {
     $app = $this->getApp();
     $this->setRequest(Request::create('/bolt'));
     $request = $this->getRequest();
     $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
     $app['dispatcher']->dispatch(KernelEvents::REQUEST, new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
     $this->assertEquals('backend', Zone::get($request));
     $this->assertTrue(Zone::isBackend($request));
 }
开发者ID:zomars,项目名称:bolt,代码行数:14,代码来源:GeneralTest.php

示例4: testControllerZone

 /**
  * @covers \Bolt\Controller\Zone::get
  * @covers \Bolt\Controller\Zone::isAsync
  */
 public function testControllerZone()
 {
     $app = $this->getApp();
     $this->allowLogin($app);
     $this->setRequest(Request::create('/async'));
     $request = $this->getRequest();
     $request->cookies->set($app['token.authentication.name'], 'dropbear');
     $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
     $app['dispatcher']->dispatch(KernelEvents::REQUEST, new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
     $this->assertEquals('async', Zone::get($request));
     $this->assertTrue(Zone::isAsync($request));
 }
开发者ID:johndotcat,项目名称:bolt,代码行数:16,代码来源:GeneralTest.php

示例5: getGlobals

 public function getGlobals()
 {
     /** @var \Bolt\Config $config */
     $config = $this->app['config'];
     /** @var \Bolt\Users $users */
     $users = $this->app['users'];
     /** @var \Bolt\Configuration\ResourceManager $resources */
     $resources = $this->app['resources'];
     $configVal = $this->safe ? null : $config;
     $usersVal = $this->safe ? null : $users->getUsers();
     $zone = null;
     /** @var RequestStack $requestStack */
     $requestStack = $this->app['request_stack'];
     if ($request = $requestStack->getCurrentRequest()) {
         $zone = Zone::get($request);
     }
     // Structured to allow PHPStorm's SymfonyPlugin to provide code completion
     return ['bolt_name' => $this->app['bolt_name'], 'bolt_version' => $this->app['bolt_version'], 'frontend' => $zone === Zone::FRONTEND, 'backend' => $zone === Zone::BACKEND, 'async' => $zone === Zone::ASYNC, 'paths' => $resources->getPaths(), 'theme' => $config->get('theme'), 'user' => $users->getCurrentUser(), 'users' => $usersVal, 'config' => $configVal];
 }
开发者ID:halechan,项目名称:bolt,代码行数:19,代码来源:TwigExtension.php

示例6: process

 /**
  * {@inheritdoc}
  */
 public function process(Request $request, Response $response)
 {
     // First, gather all html <!-- comments -->, because they shouldn't be
     // considered for replacements. We use a callback, so we can fill our
     // $this->matchedComments array
     preg_replace_callback('/<!--(.*)-->/Uis', [$this, 'pregCallback'], $response->getContent());
     /** @var Snippet $asset */
     foreach ($this->queue as $key => $asset) {
         if ($asset->getZone() === Zone::get($request)) {
             $this->injector->inject($asset, $asset->getLocation(), $response);
         }
         unset($this->queue[$key]);
     }
     // Conditionally add jQuery
     $this->addJquery($request, $response);
     // Finally, replace back ###comment### with its original comment.
     if (!empty($this->matchedComments)) {
         $html = preg_replace(array_keys($this->matchedComments), $this->matchedComments, $response->getContent(), 1);
         $response->setContent($html);
     }
 }
开发者ID:bolt,项目名称:bolt,代码行数:24,代码来源:Queue.php

示例7: determineZone

 private function determineZone()
 {
     if (PHP_SAPI === 'cli') {
         return 'cli';
     }
     /** @var \Symfony\Component\HttpFoundation\RequestStack $stack */
     $stack = $this->app['request_stack'];
     $request = $stack->getCurrentRequest() ?: Request::createFromGlobals();
     if ($zone = Zone::get($request)) {
         return $zone;
     }
     /** @var \Bolt\EventListener\ZoneGuesser $guesser */
     $guesser = $this->app['listener.zone_guesser'];
     return $guesser->setZone($request);
 }
开发者ID:errogaht,项目名称:bolt,代码行数:15,代码来源:Config.php

示例8: processAsset

 /**
  * Process a single asset.
  *
  * @param FileAssetInterface $asset
  * @param Request            $request
  * @param Response           $response
  */
 protected function processAsset(FileAssetInterface $asset, Request $request, Response $response)
 {
     if ($asset->getZone() !== Zone::get($request)) {
         return;
     } elseif ($asset->isLate()) {
         $this->injector->inject($asset, Target::END_OF_BODY, $response);
     } elseif ($asset->getType() === 'stylesheet') {
         $this->injector->inject($asset, Target::BEFORE_CSS, $response);
     } elseif ($asset->getType() === 'javascript') {
         $this->injector->inject($asset, Target::AFTER_JS, $response);
     }
 }
开发者ID:d-m-,项目名称:bolt,代码行数:19,代码来源:Queue.php

示例9: processAsset

 /**
  * Process a single asset.
  *
  * @param FileAssetInterface $asset
  * @param Request            $request
  * @param Response           $response
  */
 protected function processAsset(FileAssetInterface $asset, Request $request, Response $response)
 {
     if ($asset->getZone() !== Zone::get($request)) {
         return;
     } elseif ($asset->isLate()) {
         if ($asset->getLocation() === null) {
             $location = Target::END_OF_BODY;
         } else {
             $location = $asset->getLocation();
         }
     } elseif ($asset->getLocation() !== null) {
         $location = $asset->getLocation();
     } else {
         $location = Target::END_OF_HEAD;
     }
     $this->injector->inject($asset, $location, $response);
 }
开发者ID:gandalf3,项目名称:bolt,代码行数:24,代码来源:Queue.php

示例10: addJquery

 /**
  * Insert jQuery, if it's not inserted already.
  *
  * Some of the patterns that 'match' are:
  * - jquery.js
  * - jquery.min.js
  * - jquery-latest.js
  * - jquery-latest.min.js
  * - jquery-1.8.2.min.js
  * - jquery-1.5.js
  *
  * @param string $html
  *
  * @return string HTML
  */
 protected function addJquery($html)
 {
     if (!$this->app['config']->get('general/add_jquery', false) && !$this->app['config']->get('theme/add_jquery', false)) {
         return $html;
     }
     $zone = Zone::FRONTEND;
     /** @var RequestStack $requestStack */
     $requestStack = $this->app['request_stack'];
     if ($request = $requestStack->getCurrentRequest()) {
         $zone = Zone::get($request);
     }
     $regex = '/<script(.*)jquery(-latest|-[0-9\\.]*)?(\\.min)?\\.js/';
     if ($zone === Zone::FRONTEND && !preg_match($regex, $html)) {
         $jqueryfile = $this->app['resources']->getPath('app/view/js/jquery-2.1.4.min.js');
         $asset = new Snippet(Target::BEFORE_JS, '<script src="' . $jqueryfile . '"></script>');
         $html = $this->app['asset.injector']->inject($asset, $asset->getLocation(), $html);
     }
     return $html;
 }
开发者ID:nuffer,项目名称:bolt,代码行数:34,代码来源:Queue.php

示例11: setGlobals

 /**
  * Get the parameters that will be used to update Bolt's registered Twig
  * globals.
  *
  * This is here as a transitory measure.
  *
  * @param bool $safe
  *
  * @return array
  */
 private function setGlobals($safe)
 {
     /** @var \Twig_Environment $twig */
     $twig = $safe ? $this->app['safe_twig'] : $this->app['twig'];
     /** @var \Bolt\Config $config */
     $config = $this->app['config'];
     $configVal = $safe ? null : $config;
     /** @var \Bolt\Users $users */
     $users = $this->app['users'];
     /** @var \Bolt\Configuration\ResourceManager $resources */
     $resources = $this->app['resources'];
     $zone = null;
     /** @var RequestStack $requestStack */
     $requestStack = $this->app['request_stack'];
     if ($request = $requestStack->getCurrentRequest()) {
         $zone = Zone::get($request);
     }
     // User calls can cause exceptions that block the exception handler
     try {
         /** @deprecated Deprecated since 3.0, to be removed in 4.0. */
         $usersVal = $safe ? null : $users->getUsers();
         $usersCur = $users->getCurrentUser();
     } catch (\Exception $e) {
         $usersVal = null;
         $usersCur = null;
     }
     $twig->addGlobal('bolt_name', Bolt\Version::name());
     $twig->addGlobal('bolt_version', Bolt\Version::VERSION);
     $twig->addGlobal('bolt_stable', Bolt\Version::isStable());
     $twig->addGlobal('frontend', $zone === Zone::FRONTEND);
     $twig->addGlobal('backend', $zone === Zone::BACKEND);
     $twig->addGlobal('async', $zone === Zone::ASYNC);
     $twig->addGlobal('paths', $resources->getPaths());
     $twig->addGlobal('theme', $config->get('theme'));
     $twig->addGlobal('user', $usersCur);
     $twig->addGlobal('users', $usersVal);
     $twig->addGlobal('config', $configVal);
 }
开发者ID:nbehier,项目名称:bolt,代码行数:48,代码来源:BootInitListener.php


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