當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。