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


PHP Console::isConsole方法代码示例

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


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

示例1: createService

 /**
  * Create and return the router
  *
  * Retrieves the "router" key of the Config service, and uses it
  * to instantiate the router. Uses the TreeRouteStack implementation by
  * default.
  *
  * @param  ServiceLocatorInterface        $serviceLocator
  * @param  string|null                     $cName
  * @param  string|null                     $rName
  * @return \Zend\Mvc\Router\RouteStackInterface
  */
 public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null)
 {
     $config = $serviceLocator->get('Config');
     $routePluginManager = $serviceLocator->get('RoutePluginManager');
     if ($rName === 'ConsoleRouter' || $cName === 'router' && Console::isConsole()) {
         // We are in a console, use console router.
         if (isset($config['console']) && isset($config['console']['router'])) {
             $routerConfig = $config['console']['router'];
         } else {
             $routerConfig = array();
         }
         $router = new ConsoleRouter($routePluginManager);
     } else {
         // This is an HTTP request, so use HTTP router
         $router = new HttpRouter($routePluginManager);
         $routerConfig = isset($config['router']) ? $config['router'] : array();
     }
     if (isset($routerConfig['route_plugins'])) {
         $router->setRoutePluginManager($routerConfig['route_plugins']);
     }
     if (isset($routerConfig['routes'])) {
         $router->addRoutes($routerConfig['routes']);
     }
     if (isset($routerConfig['default_params'])) {
         $router->setDefaultParams($routerConfig['default_params']);
     }
     return $router;
 }
开发者ID:totolouis,项目名称:ZF2-Auth,代码行数:40,代码来源:RouterFactory.php

示例2: __invoke

 /**
  * @param  ContainerInterface $container
  * @return ConsoleRequest|HttpRequest
  */
 public function __invoke(ContainerInterface $container)
 {
     if (Console::isConsole()) {
         return new ConsoleRequest();
     }
     return new HttpRequest();
 }
开发者ID:zfcampus,项目名称:zf-content-negotiation,代码行数:11,代码来源:RequestFactory.php

示例3: getCookieManager

 /**
  * Construct the cookie manager.
  *
  * @param ServiceManager $sm Service manager.
  *
  * @return \VuFind\Cookie\CookieManager
  */
 public static function getCookieManager(ServiceManager $sm)
 {
     if (Console::isConsole()) {
         return false;
     }
     return parent::getCookieManager($sm);
 }
开发者ID:jlehmus,项目名称:NDL-VuFind2,代码行数:14,代码来源:Factory.php

示例4: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $app = $e->getApplication();
     $eventManager = $app->getEventManager();
     $sm = $app->getServiceManager();
     // initialize SessionManager
     $this->bootstrapSession($e);
     // Attach UserListener for role and UserProfile handling
     $listener = $sm->get(UserListener::class);
     $eventManager->attach($listener);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'initTranslator'), -100);
     $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'setUserLanguage'));
     // Enable BjyAuthorize when not in console mode
     if (!\Zend\Console\Console::isConsole()) {
         // Add ACL information to the Navigation view helper
         $authorize = $sm->get(Authorize::class);
         $acl = $authorize->getAcl();
         $role = $authorize->getIdentity();
         Navigation::setDefaultAcl($acl);
         Navigation::setDefaultRole($role);
     }
     /* @var $translator \Zend\I18n\Translator\Translator */
     $translator = $e->getApplication()->getServiceManager()->get('MvcTranslator');
     // add Db Loader factory
     $translator->getPluginManager()->setFactory(I18n\Translator\Loader\Db::class, I18n\Translator\Loader\Factory\DbFactory::class);
     if ($e->getRouter() instanceof \Zend\Mvc\Router\Http\TranslatorAwareTreeRouteStack) {
         $e->getRouter()->setTranslator($translator);
     }
 }
开发者ID:xelax90,项目名称:skeleton-module,代码行数:31,代码来源:Module.php

示例5: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     if (\Zend\Console\Console::isConsole()) {
         return;
     }
     $eventManager = $e->getApplication()->getEventManager();
     $services = $e->getApplication()->getServiceManager();
     $eventManager->attach(MvcEvent::EVENT_ROUTE, function (MvcEvent $e) use($services) {
         /* @var $checkPermissionsListener \Acl\Listener\CheckPermissionsListener */
         $checkPermissionsListener = $services->get('Auth/CheckPermissionsListener');
         $checkPermissionsListener->onRoute($e);
     }, -10);
     $eventManager->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $e) use($services) {
         /** @var CheckPermissionsListener $checkPermissionsListener */
         $checkPermissionsListener = $services->get('Auth/CheckPermissionsListener');
         $checkPermissionsListener->onDispatch($e);
     }, 10);
     $unauthorizedAccessListener = $services->get('UnauthorizedAccessListener');
     $unauthorizedAccessListener->attach($eventManager);
     $deactivatedUserListener = $services->get('DeactivatedUserListener');
     $deactivatedUserListener->attach($eventManager);
     $sharedManager = $eventManager->getSharedManager();
     $defaultlistener = $services->get('Auth/Listener/AuthAggregateListener');
     $defaultlistener->attachShared($sharedManager);
     $socialProfilesUnconfiguredErrorListener = new SocialProfilesUnconfiguredErrorListener();
     $socialProfilesUnconfiguredErrorListener->attach($eventManager);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:27,代码来源:Module.php

示例6: __invoke

 /**
  * Return a ConsoleViewManager if in a Console environment.
  *
  * @param ContainerInterface $container
  * @param string $name
  * @param callable $callback
  * @param null|array $options
  * @return \Zend\Mvc\Console\View\ViewManager|Zend\Mvc\View\Http\ViewManager
  */
 public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null)
 {
     if (!Console::isConsole() || !$container->has('ConsoleViewManager')) {
         return $callback();
     }
     return $container->get('ConsoleViewManager');
 }
开发者ID:zendframework,项目名称:zend-mvc-console,代码行数:16,代码来源:ViewManagerDelegatorFactory.php

示例7: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     if (\Zend\Console\Console::isConsole()) {
         return;
     }
     $eventManager = $e->getApplication()->getEventManager();
     $services = $e->getApplication()->getServiceManager();
     // TODO: Löschen sobald die Lösung mit der LoginBox klappt
     //$eventManager->attach(
     //    array(MvcEvent::EVENT_RENDER, MvcEvent::EVENT_RENDER_ERROR),
     //    array(new InjectLoginInfoListener(), 'injectLoginInfo'), -1000
     //);
     $eventManager->attach(MvcEvent::EVENT_ROUTE, function (MvcEvent $e) use($services) {
         /** @var CheckPermissionsListener $checkPermissionsListener */
         $checkPermissionsListener = $services->get('Auth/CheckPermissionsListener');
         $checkPermissionsListener->onRoute($e);
     }, -10);
     $eventManager->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $e) use($services) {
         /** @var CheckPermissionsListener $checkPermissionsListener */
         $checkPermissionsListener = $services->get('Auth/CheckPermissionsListener');
         $checkPermissionsListener->onDispatch($e);
     }, 10);
     $unauthorizedAccessListener = $services->get('UnauthorizedAccessListener');
     $unauthorizedAccessListener->attach($eventManager);
     $sharedManager = $eventManager->getSharedManager();
     $defaultlistener = $services->get('Auth/Listener/AuthAggregateListener');
     $defaultlistener->attachShared($sharedManager);
 }
开发者ID:webpants,项目名称:YAWIK,代码行数:28,代码来源:Module.php

示例8: __invoke

 /**
  * @param ContainerInterface $container
  * @param string $name
  * @param callable $callback
  * @param null|array $options
  * @return ConsoleRequest|\Zend\Http\Request
  */
 public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null)
 {
     if (!Console::isConsole()) {
         return $callback();
     }
     return new ConsoleRequest();
 }
开发者ID:zendframework,项目名称:zend-mvc-console,代码行数:14,代码来源:ConsoleRequestDelegatorFactory.php

示例9: createService

 /**
  * Create and return a request instance, according to current environment.
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ConsoleRequest|HttpRequest
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if (Console::isConsole()) {
         return new ConsoleRequest();
     }
     return new HttpRequest();
 }
开发者ID:Baft,项目名称:Zend-Form,代码行数:13,代码来源:RequestFactory.php

示例10: createService

 /**
  * Create and return a Console adapter instance.
  * In case we're not in a Console environment, return a dummy stdClass object.
  *
  * In order to disable adapter auto-detection and use a specific adapter (and charset),
  * add the following fields to application configuration, for example:
  *
  *     'console' => array(
  *         'adapter' => 'MyConsoleAdapter',     // always use this console adapter
  *         'charset' => 'MyConsoleCharset',     // always use this console charset
  *      ),
  *      'service_manager' => array(
  *          'invokables' => array(
  *              'MyConsoleAdapter' => 'Zend\Console\Adapter\Windows',
  *              'MyConsoleCharset' => 'Zend\Console\Charset\DESCG',
  *          )
  *      )
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return AdapterInterface|stdClass
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     // First, check if we're actually in a Console environment
     if (!Console::isConsole()) {
         // SM factory cannot currently return null, so we return dummy object
         return new stdClass();
     }
     // Read app config and determine Console adapter to use
     $config = $serviceLocator->get('Config');
     if (!empty($config['console']) && !empty($config['console']['adapter'])) {
         // use the adapter supplied in application config
         $adapter = $serviceLocator->get($config['console']['adapter']);
     } else {
         // try to detect best console adapter
         $adapter = Console::detectBestAdapter();
         $adapter = new $adapter();
     }
     // check if we have a valid console adapter
     if (!$adapter instanceof AdapterInterface) {
         // SM factory cannot currently return null, so we convert it to dummy object
         return new stdClass();
     }
     // Optionally, change Console charset
     if (!empty($config['console']) && !empty($config['console']['charset'])) {
         // use the charset supplied in application config
         $charset = $serviceLocator->get($config['console']['charset']);
         $adapter->setCharset($charset);
     }
     return $adapter;
 }
开发者ID:Nurik4249,项目名称:torrentpier,代码行数:51,代码来源:ConsoleAdapterFactory.php

示例11: logException

 /**
  * Логгируем информацию об исключении
  *
  * @param \Exception $e
  */
 public function logException(\Exception $e)
 {
     do {
         $context = Console::isConsole() ? $_ENV : $_SERVER;
         $this->getLogger()->crit($e->__toString(), ['context' => print_r($context, true)]);
     } while ($e = $e->getPrevious());
 }
开发者ID:Keanor,项目名称:zf2-logger,代码行数:12,代码来源:LoggerService.php

示例12: createService

 /**
  * Create and return the view manager for the console environment
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ConsoleViewManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if (!Console::isConsole()) {
         throw new ServiceNotCreatedException('ConsoleViewManager requires a Console environment; console environment not detected');
     }
     return new ConsoleViewManager();
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:13,代码来源:ConsoleViewManagerFactory.php

示例13: __invoke

 /**
  * Create and return the view manager for the console environment
  *
  * @param  ContainerInterface $container
  * @param  string $name
  * @param  null|array $options
  * @return ConsoleViewManager
  */
 public function __invoke(ContainerInterface $container, $name, array $options = null)
 {
     if (!Console::isConsole()) {
         throw new ServiceNotCreatedException('ConsoleViewManager requires a Console environment; console environment not detected');
     }
     return new ConsoleViewManager();
 }
开发者ID:zendframework,项目名称:zend-mvc-console,代码行数:15,代码来源:ConsoleViewManagerFactory.php

示例14: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $serviceManager = $e->getApplication()->getServiceManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     if (!Console::isConsole()) {
         $viewHelperManager = $serviceManager->get('ViewHelperManager');
         $formElementErrors = $viewHelperManager->get('formElementErrors');
         $formElementErrors->setMessageOpenFormat('<div class="zui-error">');
         $formElementErrors->setMessageSeparatorString('</div><div class="zui-error">');
         $formElementErrors->setMessageCloseString('</div>');
         $flashMessenger = $viewHelperManager->get('flashMessenger');
         $flashMessenger->setMessageOpenFormat('<div class="zui-alert zui-alert-%s"><p>');
         $flashMessenger->setMessageSeparatorString('</p><p>');
         $flashMessenger->setMessageCloseString('</p><span class="zui-icon zui-icon-x" role="button" tabindex="0"></span></div>');
         /** @var ManagerInterface $sessionManager */
         $sessionManager = $serviceManager->get(ManagerInterface::class);
         $sessionManager->start();
     }
     $helpers = $serviceManager->get('ViewHelperManager');
     $hal = $helpers->get('Hal');
     $hal->getEventManager()->attach('renderCollection.post', [$this, 'onRenderCollection']);
     $hal->getEventManager()->attach('renderEntity.post', [$this, 'onRenderEntity']);
 }
开发者ID:zource,项目名称:zource,代码行数:25,代码来源:Module.php

示例15: createService

 /**
  * Create and return a view manager based on detected environment
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ConsoleViewManager|HttpViewManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if (Console::isConsole()) {
         return $serviceLocator->get('ConsoleViewManager');
     }
     return $serviceLocator->get('HttpViewManager');
 }
开发者ID:leonardovn86,项目名称:zf2_basic2013,代码行数:13,代码来源:ViewManagerFactory.php


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