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


PHP Application::isAdmin方法代码示例

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


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

示例1: main

 /**
  * {@inheritdoc}
  */
 public function main(App $app)
 {
     $app['system'] = $this;
     $app['isAdmin'] = false;
     $app->factory('finder', function () {
         return Finder::create();
     });
     $app['db.em'];
     // -TODO- fix me
     $theme = $this->config('site.theme');
     foreach (array_merge($this->config['extensions'], (array) $theme) as $module) {
         try {
             $app['module']->load($module);
         } catch (\RuntimeException $e) {
             $app['log']->warn("Unable to load extension: {$module}");
         }
     }
     if (!($app['theme'] = $app->module($theme))) {
         $app['theme'] = new Module(['name' => 'default-theme', 'path' => '', 'config' => [], 'layout' => 'views:system/blank.php']);
     }
     $app->extend('view', function ($view) use($app) {
         $theme = $app->isAdmin() ? $app->module('system/theme') : $app['theme'];
         $view->map('layout', $theme->get('layout', 'views:template.php'));
         return $view->addGlobal('theme', $app['theme']);
     });
 }
开发者ID:birah,项目名称:pagekit,代码行数:29,代码来源:SystemModule.php

示例2: main

 /**
  * {@inheritdoc}
  */
 public function main(App $app)
 {
     $app['system'] = $this;
     $app['isAdmin'] = false;
     $app->factory('finder', function () {
         return Finder::create();
     });
     $app['db.em'];
     // -TODO- fix me
     $app->extend('view', function ($view) use($app) {
         $theme = $app->isAdmin() ? $app->module('system/theme') : $app['theme'];
         $view->map('layout', $theme->get('layout', 'views:template.php'));
         return $view->addGlobal('theme', $app['theme']);
     });
     $app->extend('assets', function ($factory) use($app) {
         $secret = $this->config['secret'];
         $version = substr(sha1($app['version'] . $secret), 0, 4);
         $factory->setVersion($version);
         return $factory;
     });
     $theme = $this->config('site.theme');
     $app['module']->addLoader(function ($module) use($app, $theme) {
         if (in_array($module['name'], $this->config['extensions'])) {
             $module['type'] = 'extension';
             $app['locator']->add("{$module['name']}:", $module['path']);
             $app['locator']->add("views:{$module['name']}", "{$module['path']}/views");
         } else {
             if ($module['name'] == $theme) {
                 $module['type'] = 'theme';
                 $app['locator']->add('theme:', $module['path']);
                 $app['locator']->add('views:', "{$module['path']}/views");
             }
         }
         return $module;
     });
     foreach (array_merge($this->config['extensions'], (array) $theme) as $module) {
         try {
             $app['module']->load($module);
         } catch (\RuntimeException $e) {
             $module = ucfirst($module);
             $app['log']->error("[{$module} exception]: {$e->getMessage()}");
         }
     }
     if (!($app['theme'] = $app->module($theme))) {
         $app['theme'] = new Module(['name' => 'theme-default', 'type' => 'theme', 'path' => '', 'config' => [], 'layout' => 'views:system/blank.php']);
     }
 }
开发者ID:aqnouch,项目名称:rimbo,代码行数:50,代码来源:SystemModule.php

示例3: onRequest

 /**
  * Puts the page in maintenance mode.
  */
 public function onRequest($event, $request)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $site = App::module('system/site');
     if ($site->config('maintenance.enabled') && !(App::isAdmin() || $request->attributes->get('_maintenance') || App::user()->hasAccess('site: maintenance access'))) {
         $message = $site->config('maintenance.msg') ?: __("We'll be back soon.");
         $response = App::view('system/theme:views/maintenance.php', compact('message'));
         $request->attributes->set('_disable_debugbar', true);
         $types = $request->getAcceptableContentTypes();
         if ('json' == $request->getFormat(array_shift($types))) {
             $response = App::response()->json($message, 503);
         } else {
             $response = App::response($response, 503);
         }
         $event->setResponse($response);
     }
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:22,代码来源:MaintenanceListener.php

示例4: onRequest

 /**
  * Puts the page in maintenance mode.
  */
 public function onRequest($event, $request)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $site = App::module('system/site');
     if ($site->config('maintenance.enabled') && !(App::isAdmin() || $request->attributes->get('_maintenance') || App::user()->hasAccess('site: maintenance access') || App::user()->hasAccess('system: access admin area'))) {
         $message = $site->config('maintenance.msg') ?: __("We'll be back soon.");
         $logo = $site->config('maintenance.logo') ?: 'app/system/assets/images/pagekit-logo-large-black.svg';
         $response = App::view('system/theme:views/maintenance.php', compact('message', 'logo'));
         $request->attributes->set('_disable_debugbar', true);
         $types = $request->getAcceptableContentTypes();
         if (!App::user()->isAuthenticated() && $request->isXMLHttpRequest()) {
             App::abort('401', 'Unauthorized');
         } elseif ('json' == $request->getFormat(array_shift($types))) {
             $response = App::response()->json($message, 503);
         } else {
             $response = App::response($response, 503);
         }
         $event->setResponse($response);
     }
 }
开发者ID:pagekit,项目名称:pagekit,代码行数:25,代码来源:MaintenanceListener.php


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