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


PHP MvcEvent::getParam方法代码示例

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


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

示例1: injectIntoView

 /**
  * Sets some Meta-Data into the view.
  * 
  * @param MvcEvent $event
  */
 public function injectIntoView(MvcEvent $event)
 {
     $serviceLocator = $event->getApplication()->getServiceManager();
     $nodeOptions = $serviceLocator->get('NodeOptions');
     /* @var $nodeOptions \Node\Options\NodeOptions */
     $viewHelperManager = $serviceLocator->get('viewhelpermanager');
     $serverurl = $viewHelperManager->get('serverurl');
     if (null != $event->getParam('matchedNode')) {
         $node = $event->getParam('matchedNode');
         /* @var $node \Node\Entity\NodeInterface */
         // HeadTitle
         $headtitle = $viewHelperManager->get('headtitle');
         $headtitle->set($node->getNodeName());
         // Canonical
         $headlink = $viewHelperManager->get('headlink');
         $headlink(['rel' => 'canonical', 'href' => $serverurl() . $node->getNodeRoute()]);
         // Meta?
         if (true == $nodeOptions->getEnableMetaTags()) {
             $headmeta = $viewHelperManager->get('headmeta');
             if (null != $node->getNodeMetaRobots()) {
                 $headmeta->appendName('robots', $node->getNodeMetaRobots());
             }
             if (null != $node->getNodeMetaDescription()) {
                 $headmeta->appendName('description', $node->getNodeMetaDescription());
             }
             if (null != $node->getNodeMetaKeywords()) {
                 $headmeta->appendName('keywords', $node->getNodeMetaKeywords());
             }
         }
     }
 }
开发者ID:alexsawallich,项目名称:node,代码行数:36,代码来源:MvcListenerAggregate.php

示例2: testNoRolesAllowed

 public function testNoRolesAllowed()
 {
     $this->routeMatch->setParam('action', 'noRoles');
     $listener = new Authorized();
     $listener->onDispach($this->event);
     $this->assertNull($this->event->getParam('exception'));
 }
开发者ID:gontero,项目名称:gontero-acl,代码行数:7,代码来源:AuthorizedListenerTest.php

示例3: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $e->getApplication()->getServiceManager()->get('translator');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // Add translation
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $setLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     } else {
         $setLang = '';
     }
     $translator->setLocale(\Locale::acceptFromHttp($setLang))->setFallbackLocale('en_US');
     // Add ACL information to the Navigation view helper
     $sm = $e->getApplication()->getServiceManager();
     $authorize = $sm->get('BjyAuthorize\\Service\\Authorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     \Zend\View\Helper\Navigation::setDefaultAcl($acl);
     \Zend\View\Helper\Navigation::setDefaultRole($role);
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Application', 'dispatch.error', function ($e) use($sm) {
         if ($e->getParam('exception')) {
             $sm->get('Zend\\Log\\Logger')->crit($e->getParam('exception'));
         }
     });
 }
开发者ID:riceri,项目名称:MvitInvoice,代码行数:27,代码来源:Module.php

示例4: dispatchError

 public function dispatchError(MvcEvent $e)
 {
     $sharedManager = $e->getApplication()->getEventManager()->getSharedManager();
     $sharedManager->attach('Zend\\Mvc\\Application', 'dispatch.error', function ($e) {
         if ($e->getParam('exception')) {
             ob_clean();
             //Limpar a tela de erros do php
             header('HTTP/1.1 400 Bad Request');
             $exception = $e->getParam('exception');
             $sm = $e->getApplication()->getServiceManager();
             $config = $sm->get('Config');
             $e->getApplication()->getServiceManager()->get('Controller\\Plugin\\Manager')->get('jsLog')->log($exception, 2);
             $viewModel = new \Zend\View\Model\ViewModel(['exception' => $exception]);
             if ($e->getRequest()->isXmlHttpRequest()) {
                 $viewModel->setTemplate($config['js_library']['error_ajax_exception']);
                 $e->getApplication()->getServiceManager()->get('ViewRenderer')->render($viewModel);
             } else {
                 $viewModel->setTemplate($config['js_library']['error_exception']);
                 echo $e->getApplication()->getServiceManager()->get('ViewRenderer')->render($viewModel);
             }
             /*
              * Com erros handler o codigo continua a ser executado,
              * entao o exit para e so mostra os erros
              */
             exit;
         }
     });
 }
开发者ID:argentinaluiz,项目名称:js_zf2_library,代码行数:28,代码来源:Module.php

示例5: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $events = $e->getApplication()->getEventManager()->getSharedManager();
     $config = $e->getApplication()->getServiceManager()->get('config');
     // configure session
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config['session']);
     $events->attach('ZfcUser\\Service\\User', 'register.post', function ($e) {
         $user = $e->getParam('user');
         // User account object
         $form = $e->getParam('form');
         // Form object
         // Perform your custom action here
         /* @var $sm ServiceLocatorInterface */
         $sm = $e->getTarget()->getServiceManager();
         /* @var $em \Doctrine\ORM\EntityManager */
         $em = $sm->get('doctrine.entitymanager.orm_default');
         $userRole = $em->find(__NAMESPACE__ . '\\Entity\\UserRole', DEFAULT_ROLE);
         if (NULL !== $userRole) {
             $user->addRole($userRole);
             $em->persist($user);
             $em->flush();
         }
     });
 }
开发者ID:gaelcost,项目名称:room-management-system,代码行数:25,代码来源:Module.php

示例6: onError

 /**
  * Listener callback
  */
 public function onError()
 {
     $this->verifyIsError();
     /** @var \Exception $exception */
     $exception = $this->mvcEvent->getParam('exception');
     $logger = $this->getLogger();
     $logger->err($exception);
 }
开发者ID:jakubigla,项目名称:zf-log,代码行数:11,代码来源:ErrorListener.php

示例7: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $doctrineAdapter = $serviceManager = $e->getParam('application')->getServiceManager()->get('oauth2.doctrineadapter.default');
     $listenerAggregate = new \ZFTest\OAuth2\Doctrine\Listener\TestEvents($doctrineAdapter);
     /** @var ServiceManager $serviceManager */
     $serviceManager = $e->getParam('application')->getServiceManager();
     /** @var EventManager $eventManager */
     $eventManager = $serviceManager->get('oauth2.doctrineadapter.default')->getEventManager();
     $listenerAggregate->attach($eventManager);
 }
开发者ID:api-skeletons,项目名称:zf-oauth2-doctrine,代码行数:10,代码来源:Module.php

示例8: loadDocument

 protected function loadDocument(MvcEvent $event, $documentManager, $metadata, $field)
 {
     if (!($document = $event->getParam('document'))) {
         // document not set, so load it
         $document = $documentManager->createQueryBuilder()->find($metadata->name)->field($event->getTarget()->getOptions()->getProperty())->equals($event->getParam('id'))->select($field)->getQuery()->getSingleResult();
         if (!$document) {
             throw new Exception\DocumentNotFoundException();
         }
     }
     return $document;
 }
开发者ID:zoopcommerce,项目名称:shard-module,代码行数:11,代码来源:LoadDocumentTrait.php

示例9: handleError

 /**
  *
  */
 public function handleError(MvcEvent $event)
 {
     $controller = $event->getController();
     $error = $event->getParam('error');
     $exception = $event->getParam('exception');
     $message = sprintf('Error dispatching controller "%s". Error was: "%s"', $controller, $error);
     if ($exception instanceof \Exception) {
         $message .= ', Exception(' . $exception->getMessage() . '): ' . $exception->getTraceAsString();
     }
     error_log($message);
 }
开发者ID:mafkes,项目名称:socialNetwork,代码行数:14,代码来源:Module.php

示例10: onBootstrap

 /**
  * Bootstrap.
  *
  * @var MvcEvent $e
  */
 public function onBootstrap(MvcEvent $e)
 {
     $em = $e->getApplication()->getEventManager();
     // this event listener will turn the request into '403 Forbidden' when
     // there is a NotAllowedException
     $em->attach(MvcEvent::EVENT_DISPATCH_ERROR, function ($e) {
         if ($e->getError() == 'error-exception' && $e->getParam('exception', null) != null && $e->getParam('exception') instanceof NotAllowedException) {
             $e->getResult()->setTemplate('error/403');
             $e->getResponse()->setStatusCode(403);
         }
     }, -100);
 }
开发者ID:efueger,项目名称:gewisweb,代码行数:17,代码来源:Module.php

示例11: latch

 public function latch(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $em = $eventManager->getSharedManager();
     $zfcServiceEvents = $e->getApplication()->getServiceManager()->get('zfcuser_user_service')->getEventManager();
     $zfcServiceEvents->attach('register', function ($e) {
         $form = $e->getParam('form');
         /* @var $user \FzyAuth\Entity\Base\UserInterface */
         $user = $e->getParam('user');
         $user->setRole(UserInterface::ROLE_USER);
     });
 }
开发者ID:fousheezy,项目名称:auth,代码行数:12,代码来源:Register.php

示例12: _addRegistrationFields

 private function _addRegistrationFields(MvcEvent $e)
 {
     $zfcServiceEvents = $e->getApplication()->getServiceManager()->get('zfcuser_user_service')->getEventManager();
     // Store the field
     $zfcServiceEvents->attach('register', function ($e) {
         $form = $e->getParam('form');
         $user = $e->getParam('user');
         /* @var $user \FooUser\Entity\User */
         $displayName = $form->get('firstName')->getValue() . ' ' . $form->get('lastName')->getValue();
         $user->setDisplayName($displayName);
     });
 }
开发者ID:NewtonsNerds,项目名称:INerdsDashboard,代码行数:12,代码来源:Module.php

示例13: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $application = $e->getApplication();
     $serviceLocator = $application->getServiceManager();
     $application->getEventManager()->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (Event $e) use($serviceLocator) {
         $exception = $e->getParam('exception');
         $serviceLocator->get('Zend\\Log\\Logger')->crit($exception);
     });
     $application->getEventManager()->attach(MvcEvent::EVENT_RENDER_ERROR, function (Event $e) use($serviceLocator) {
         $exception = $e->getParam('exception');
         $serviceLocator->get('Zend\\Log\\Logger')->crit($exception);
     });
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:13,代码来源:Module.php

示例14: unserializeSingle

 public function unserializeSingle(MvcEvent $event, $mode)
 {
     if (count($event->getParam('deeperResource')) > 0 || ($result = $event->getResult())) {
         return $event->getResult();
     }
     $data = $event->getParam('data');
     $id = $event->getParam('id');
     $options = $event->getTarget()->getOptions();
     if ($property = $options->getProperty()) {
         $data[$property] = $id;
     }
     $result = new Result($event->getTarget()->getOptions()->getManifest()->getServiceManager()->get('unserializer')->fromArray($data, $event->getTarget()->getOptions()->getClass(), $event->getParam('document'), $mode));
     $event->setResult($result);
     return $result;
 }
开发者ID:zoopcommerce,项目名称:shard-module,代码行数:15,代码来源:UnserializeListener.php

示例15: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $events = StaticEventManager::getInstance();
     $serviceManager = $e->getApplication()->getServiceManager();
     $appConfig = $serviceManager->get('Config');
     $logger = new Logger();
     if (!isset($appConfig['operation_logger'])) {
         throw new \RuntimeException("Logger not properly configured");
     }
     if (!isset($appConfig['operation_logger']['priority_filter'])) {
         throw new \RuntimeException("You must specify a 'priority_filter' config param");
     }
     $logFilter = new PriorityFilter($appConfig['operation_logger']['priority_filter']);
     if (!is_null($appConfig['operation_logger']['db_adapter'])) {
         if (empty($appConfig['operation_logger']['logger_table'])) {
             throw new \RuntimeException("You must specify a 'logger_table' config param");
         }
         $dbAdapter = $serviceManager->get($appConfig['operation_logger']['db_adapter']);
         if (!$dbAdapter instanceof \Zend\Db\Adapter\Adapter) {
             throw new \RuntimeException("Failed to load database adapter for logger");
         }
         $tableMapping = array('timestamp' => 'event_date', 'priorityName' => 'priority', 'message' => 'event', 'extra' => array('id_operation_log' => 'id_operation_log', 'note' => 'note', 'table' => 'table_name', 'id_user' => 'id_user', 'username' => 'username', 'id_row' => 'id_row', 'field' => 'field', 'value_old' => 'value_old', 'value_new' => 'value_new', 'source' => 'source', 'uri' => 'uri', 'ip' => 'ip', 'session_id' => 'session_id'));
         $logWriter = new DbWriter($dbAdapter, $appConfig['operation_logger']['logger_table'], $tableMapping);
         $logWriter->addFilter($logFilter);
         $logger->addWriter($logWriter);
     }
     // nel caso si volgia fare un file LOG
     if (isset($appConfig['operation_logger']['log_file']) && !is_null($appConfig['operation_logger']['log_file'])) {
         $streamWriter = new StreamWriter($appConfig['operation_logger']['log_file']);
         $streamWriter->addFilter($logFilter);
         $logger->addWriter($streamWriter);
     }
     $request = $e->getApplication()->getRequest();
     $remoteAddress = new RemoteAddress();
     Logger::registerErrorHandler($logger, true);
     Logger::registerExceptionHandler($logger);
     // Attacco evento per trigger LOG! (evento: operation-log)
     $events->attach("*", 'operation-log', function (\Zend\EventManager\Event $e) use($logger, $request, $remoteAddress, $serviceManager) {
         $targetClass = get_class($e->getTarget());
         $message = $e->getParam('message');
         $priority = $e->getParam('priority', Logger::INFO);
         $zfcAuthEvents = $serviceManager->get('zfcuser_auth_service');
         $idUser = $zfcAuthEvents->hasIdentity() ? $zfcAuthEvents->getIdentity()->getId() : (array_key_exists('id_user', $message) ? $message['id_user'] : 'guest');
         $displayName = $zfcAuthEvents->hasIdentity() ? $zfcAuthEvents->getIdentity()->getDisplayName() : (array_key_exists('username', $message) ? $message['username'] : 'guest');
         $extras = array('id_operation_log' => null, 'note' => array_key_exists('note', $message) ? $message['note'] : null, 'table_name' => array_key_exists('table', $message) ? $message['table'] : null, 'operation' => array_key_exists('operation', $message) ? $message['operation'] : null, 'id_user' => $idUser, 'username' => $displayName, 'id_row' => array_key_exists('id_row', $message) ? $message['id_row'] : null, 'field' => array_key_exists('field', $message) ? $message['field'] : null, 'value_old' => array_key_exists('value_old', $message) ? $message['value_old'] : null, 'value_new' => array_key_exists('value_new', $message) ? $message['value_new'] : null, 'source' => $targetClass, 'uri' => $request->getUriString(), 'ip' => $remoteAddress->getIpAddress(), 'session_id' => session_id());
         $logger->log($priority, $message['message'], $extras);
     });
 }
开发者ID:savez,项目名称:zf-operation-log,代码行数:48,代码来源:Module.php


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