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


PHP Console\Console类代码示例

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


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

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

示例2: onBootstrap

 public function onBootstrap(MvcEvent $mvcEvent)
 {
     if (Console::isConsole()) {
         return;
     }
     $application = $mvcEvent->getApplication();
     $serviceLocator = $application->getServiceManager();
     $strategy = $serviceLocator->get(AccessListener::class);
     $eventManager = $application->getEventManager();
     $strategy->attach($eventManager);
     //            try {
     //                $remote = new RemoteAddress;
     //                $remote->setUseProxy(true);
     //                $mapper = $serviceManager->get(UserAuthenticationLogMapper::class);
     //                $logEntity = new UserAuthenticationLog(
     //                    $authEvent->getIdentity(),
     //                    new \DateTime("now"),
     //                    $remote->getIpAddress()
     //                );
     //                $mapper->save($logEntity);
     //
     //            } catch (\Exception $x) {
     //
     //            }
     //        });
 }
开发者ID:saeven,项目名称:zf3-circlical-user,代码行数:26,代码来源:Module.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: 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

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

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

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

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

示例9: passwordAction

 public function passwordAction()
 {
     $request = $this->getRequest();
     // Make sure that we are running in a console and the user has not
     // tricked our
     // application into running this action from a public web server.
     if (!$request instanceof ConsoleRequest) {
         throw new \RuntimeException('You can only use this action from a console!');
     }
     // Get user email from console and check if the user used --verbose or
     // -v flag
     $userEmail = $request->getParam('userEmail');
     $verbose = $request->getParam('verbose');
     // reset new password
     $newPassword = Rand::getString(16);
     $console = Console::getInstance();
     if (Confirm::prompt('Is this the correct answer? [y/n]', 'y', 'n')) {
         $console->write("You chose YES\n");
     } else {
         $console->write("You chose NO\n");
     }
     if (!$verbose) {
         return "Done! {$userEmail} has received an email with his new password.\n";
     } else {
         return "Done! New password for user {$userEmail} is '{$newPassword}'. It has also been emailed to him. \n";
     }
 }
开发者ID:EngrHaiderAli,项目名称:movein-ui,代码行数:27,代码来源:WorkerController.php

示例10: getIP

 public static function getIP($just_remote = true)
 {
     if (Console::isConsole()) {
         return '127.0.0.1';
     }
     // O único realmente seguro de se confiar é o REMOTE_ADDR
     $validator = new \Zend\Validator\Ip();
     $remote = $_SERVER['REMOTE_ADDR'];
     if (!$validator->isValid($remote)) {
         throw new \RuntimeException("Endereço de IP '{$remote}' inválido");
     }
     if ($just_remote) {
         return $remote;
     }
     $ips = [$remote];
     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
         $ip = $_SERVER['HTTP_CLIENT_IP'];
         if ($validator->isValid($ip)) {
             $ips[2] = $ip;
         }
     } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
         if ($validator->isValid($ip)) {
             $ips[1] = $ip;
         }
     }
     return $ips;
 }
开发者ID:lafaiDev,项目名称:suive_com,代码行数:28,代码来源:Util.php

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

示例12: __invoke

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

示例13: createService

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

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

示例15: getConsoleAdapter

 /**
  *
  * @return ConsoleAdapter
  */
 public function getConsoleAdapter()
 {
     if (null === $this->consoleAdapter) {
         $this->consoleAdapter = Console::getInstance();
     }
     return $this->consoleAdapter;
 }
开发者ID:rezix,项目名称:ZfcDatagrid,代码行数:11,代码来源:Renderer.php


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