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


PHP EventManager\Event类代码示例

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


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

示例1: dispatch

 /**
  * Determines if we're dealing with the required Resource
  * before dispatching to actions
  *
  * @param Event $e
  * @return mixed|void
  */
 public function dispatch(Event $e)
 {
     switch ($e->getName()) {
         case 'create.post':
         case 'update.post':
         case 'patch.post':
             /**
              * Redirect client to newly created resource
              */
             $controller = $e->getTarget();
             if ($controller instanceof ResourceController) {
                 $resource = $controller->getResource();
                 if ($resource instanceof Resource) {
                     $model = $e->getParam('resource');
                     if ($model instanceof ResourceJsonModel) {
                         $object = $model->getPayload();
                         if ($object instanceof BackendResourceInterface) {
                             $e->stopPropagation(true);
                             $response = $controller->redirect()->toRoute('api/default', array('resource' => $resource->getIdentifier(), 'id' => $object->getId()));
                             return $response;
                             //@TODO remove until fixed CORS redirect
                         }
                     }
                 }
             }
             break;
     }
 }
开发者ID:parrotcage,项目名称:aves,代码行数:35,代码来源:ResourceListenerAggregate.php

示例2: onBootstrap

 public function onBootstrap(Event $e)
 {
     $app = $e->getApplication();
     Utility::setSM($app->getServiceManager());
     TransactionUtility::setSM($app->getServiceManager());
     UnitCalcUtility::setSM($app->getServiceManager());
 }
开发者ID:binnguyen,项目名称:kaffabasic,代码行数:7,代码来源:Module.php

示例3: onUpdate

 public function onUpdate(Event $e)
 {
     /* @var $term TaxonomyTermInterface */
     $term = $e->getParam('term');
     $instance = $term->getInstance();
     $this->logEvent('taxonomy/term/update', $instance, $term);
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:7,代码来源:TaxonomyManagerListener.php

示例4: initListener

 /**
  * Initialize event listener
  * @param \Zend\EventManager\Event $e
  * @return void
  */
 public function initListener(Event $e)
 {
     $app = $e->getParam('application');
     $eventListener = new Listener();
     $eventListener->setServiceManager($app->getServiceManager());
     $app->getEventManager()->attachAggregate($eventListener);
 }
开发者ID:Ellipizle,项目名称:dotscms,代码行数:12,代码来源:Module.php

示例5: __invoke

 /**
  * @param array|null $resource
  * @param Request    $request
  * @param Response   $response
  */
 public function __invoke(Event $event)
 {
     $resource = $event->getParam('resource');
     $response = $event->getParam('response');
     $body = $this->renderView($resource, $response);
     $response->setBody($body);
 }
开发者ID:comphppuebla,项目名称:restful-extensions,代码行数:12,代码来源:RenderResourceListener.php

示例6: onDispatch

 public function onDispatch(Event $event)
 {
     $controller = $event->getTarget();
     if (!$controller instanceof AbstractController) {
         return;
     }
     $entity = $controller->getEntity();
     if (!$entity) {
         return;
     }
     $terms = $entity->getTaxonomyTerms();
     if ($terms->isEmpty()) {
         foreach ($entity->getParents('link') as $parent) {
             $terms = $parent->getTaxonomyTerms();
             if (!$terms->isEmpty()) {
                 break;
             }
         }
     }
     $term = $this->strategy->findBranch($terms);
     if ($term) {
         /* @var $navigationFactory DefaultNavigationFactory */
         $navigationFactory = $controller->getServiceLocator()->get('Navigation\\Factory\\DefaultNavigationFactory');
         $params = ['term' => $term->getId(), 'controller' => 'Taxonomy\\Controller\\GetController', 'action' => 'index'];
         $routeMatch = new RouteMatch($params);
         $routeMatch->setMatchedRouteName('taxonomy/term/get');
         $navigationFactory->setRouteMatch($routeMatch);
     }
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:29,代码来源:AbstractDispatchListener.php

示例7: preSend

 /**
  * Add Client Id and Client Secret to Request Parameters
  *
  * @throws Exception\InvalidArgumentException
  */
 public function preSend(Event $e)
 {
     $this->request = $e->getTarget();
     $headers = $this->request->getHeaders();
     $params = array('Authorization' => 'OAuth ' . $this->getOauthString());
     $headers->addHeaders($params);
 }
开发者ID:hounddog,项目名称:hd-twitter,代码行数:12,代码来源:OAuth.php

示例8: onCreate

 public function onCreate(Event $e)
 {
     $entity = $e->getParam('entity');
     $user = $this->getUserManager()->getUserFromAuthenticator();
     $instance = $this->getInstanceManager()->getInstanceFromRequest();
     $this->logEvent('entity/create', $instance, $entity);
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:7,代码来源:EntityManagerListener.php

示例9: onBootstrap

 public function onBootstrap(Event $e)
 {
     $sm = $e->getApplication()->getServiceManager();
     $em = $sm->get('doctrine.entitymanager.orm_default');
     $vcard = $sm->get('vcard');
     $vcard->setEm($em);
 }
开发者ID:heartsentwined,项目名称:zf2-vcard,代码行数:7,代码来源:Module.php

示例10: clearCache

 public function clearCache($id)
 {
     $event = new Event();
     $event->setParam('id', $id);
     $result = $this->getEventManager()->trigger('clear', $event);
     return $result->last();
 }
开发者ID:zource,项目名称:zource,代码行数:7,代码来源:CacheManager.php

示例11: onTrash

 public function onTrash(Event $e)
 {
     $object = $e->getParam('object');
     $user = $this->getUserManager()->getUserFromAuthenticator();
     $instance = $this->getInstanceManager()->getInstanceFromRequest();
     $this->logEvent('uuid/trash', $instance, $object);
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:7,代码来源:UuidManagerListener.php

示例12: onCancelSingle

 public function onCancelSingle(Event $event)
 {
     $booking = $event->getTarget();
     $reservations = $this->reservationManager->getBy(['bid' => $booking->need('bid')], 'date ASC', 1);
     $reservation = current($reservations);
     $square = $this->squareManager->get($booking->need('sid'));
     $user = $this->userManager->get($booking->need('uid'));
     $dateRangerHelper = $this->dateRangeHelper;
     $reservationTimeStart = explode(':', $reservation->need('time_start'));
     $reservationTimeEnd = explode(':', $reservation->need('time_end'));
     $reservationStart = new \DateTime($reservation->need('date'));
     $reservationStart->setTime($reservationTimeStart[0], $reservationTimeStart[1]);
     $reservationEnd = new \DateTime($reservation->need('date'));
     $reservationEnd->setTime($reservationTimeEnd[0], $reservationTimeEnd[1]);
     $subject = sprintf($this->t('Your %s-booking has been cancelled'), $this->optionManager->get('subject.square.type'));
     $message = sprintf($this->t('we have just cancelled %s %s, %s for you.'), $this->optionManager->get('subject.square.type'), $square->need('name'), $dateRangerHelper($reservationStart, $reservationEnd));
     if ($user->getMeta('notification.bookings', 'true') == 'true') {
         $this->userMailService->send($user, $subject, $message);
     }
     if ($this->optionManager->get('client.contact.email.user-notifications')) {
         $backendSubject = sprintf($this->t('%s\'s %s-booking has been cancelled'), $user->need('alias'), $this->optionManager->get('subject.square.type'));
         $addendum = sprintf($this->t('Originally sent to %s (%s).'), $user->need('alias'), $user->need('email'));
         $this->backendMailService->send($backendSubject, $message, array(), $addendum);
     }
 }
开发者ID:Bertie1708,项目名称:ep3-bs,代码行数:25,代码来源:NotificationListener.php

示例13: testTriggerSetsTarget

 public function testTriggerSetsTarget()
 {
     $event = new Event();
     $this->assertNull($event->getTarget());
     Reflection::invoke($this->sut, 'trigger', array($event));
     $this->assertSame($this->sut, $event->getTarget());
 }
开发者ID:kkucera,项目名称:XssModule,代码行数:7,代码来源:CompanyTest.php

示例14: updateSchema

 /**
  * {@inheritDoc}
  */
 public function updateSchema(Event $e)
 {
     $moduleVersion = $e->getParam('version');
     // Set extra model
     $extraModel = Pi::model('extra', $this->module);
     $extraTable = $extraModel->getTable();
     $extraAdapter = $extraModel->getAdapter();
     // Set news story model
     $newsStoryModel = Pi::model('story', 'news');
     $newsStoryTable = $newsStoryModel->getTable();
     $newsStoryAdapter = $newsStoryModel->getAdapter();
     // Update to version 0.1.5
     if (version_compare($moduleVersion, '0.1.5', '<')) {
         // Update value
         $select = $extraModel->select();
         $rowSet = $extraModel->selectWith($select);
         foreach ($rowSet as $row) {
             // Set time
             $time = $row->time_end ? $row->time_end : $row->time_start;
             // Update time_publish
             $newsStoryModel->update(array('time_publish' => $time), array('id' => $row->id));
         }
     }
     // Update to version 0.4.1
     if (version_compare($moduleVersion, '0.4.1', '<')) {
         // Alter table field `register_discount`
         $sql = sprintf("ALTER TABLE %s ADD `register_discount` TEXT", $extraTable);
         try {
             $extraAdapter->query($sql, 'execute');
         } catch (\Exception $exception) {
             $this->setResult('db', array('status' => false, 'message' => 'Table alter query failed: ' . $exception->getMessage()));
             return false;
         }
     }
 }
开发者ID:pi-module,项目名称:event,代码行数:38,代码来源:Update.php

示例15: checkModules

 /**
  * Check other modules and register comments if available
  *
  * @param Event $e
  * @return void
  */
 public function checkModules(Event $e)
 {
     $module = $e->getParam('module');
     $modules = Pi::registry('module')->read();
     if (isset($modules['comment'])) {
         unset($modules['comment']);
     }
     $moduleList = array_keys($modules);
     foreach ($moduleList as $mod) {
         $options = Pi::service('module')->loadMeta($mod, 'comment', true);
         if (empty($options)) {
             continue;
         }
         /*
         if (is_string($options)) {
             $optionsFile = sprintf(
                 '%s/%s/config/%s',
                 Pi::path('module'),
                 Pi::service('module')->directory($mod),
                 $options
             );
             $options = include $optionsFile;
             if (empty($options) || !is_array($options)) {
                 continue;
             }
         }
         */
         $resourceHandler = new CommentResource($options);
         $e->setParam('module', $mod);
         $resourceHandler->setEvent($e);
         $resourceHandler->installAction();
     }
     $e->setParam('module', $module);
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:40,代码来源:Install.php


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