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


PHP Event::getTarget方法代码示例

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



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

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


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


示例3: checkUserExists

 public function checkUserExists(Event $e, $username)
 {
     $sm = $e->getTarget()->getServiceManager();
     $mapper = $sm->get('apiuser_user_mapper');
     $userObject = $mapper->findByUsername($username);
     return $userObject ? true : false;
 }
开发者ID:arstropica,项目名称:zf-tenstreet,代码行数:7,代码来源:Register.php


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


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


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


示例7: onLoadModules

 public function onLoadModules(Event $e)
 {
     $moduleManager = $e->getTarget();
     $modules = $moduleManager->getModules();
     // Hier kommt die Superglobal $_ENV rein
     $moduleManager->setModules($modules);
 }
开发者ID:bitrecruiter,项目名称:CrossApplicantManager,代码行数:7,代码来源:ModuleManagerFactory.php


示例8: onBypass

 /**
  * @param Event $e
  * @throws \Instance\Exception\RuntimeException
  */
 public function onBypass(Event $e)
 {
     $target = $e->getTarget();
     if (!$target instanceof InstanceProviderInterface) {
         throw new Exception\RuntimeException(sprintf('Expected instance of InstanceProviderInterface but got %s.', is_object($target) ? get_class($target) : gettype($target)));
     }
     $this->instanceManager->switchInstance($target->getInstance());
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:12,代码来源:IsolationBypassedListener.php


示例9: disableValidatorAnnotationForDoctrine

 public function disableValidatorAnnotationForDoctrine(Event $e)
 {
     if (class_exists('Doctrine\\Common\\Annotations\\AnnotationReader')) {
         $moduleManager = $e->getTarget();
         $config = $moduleManager->getModule('AnnotationValidator')->getConfig();
         AnnotationReader::addGlobalIgnoredName($config['validator_annotation']);
     }
 }
开发者ID:ibekiaris,项目名称:zf2-annotation-validator,代码行数:8,代码来源:Module.php


示例10: onCreate

 public function onCreate(Event $e)
 {
     /* var $entity \Entity\Entity\EntityInterface */
     $entity = $e->getParam('entity');
     $result = new UrlResult();
     $result->setResult($e->getTarget()->url()->fromRoute('entity/repository/add-revision', ['entity' => $entity->getId()]));
     return $result;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:8,代码来源:EntityControllerListener.php


示例11: setData

 /**
  * Sets the query parameters to the paginator
  * 
  * @param Event $event Event
  * 
  * @return void
  */
 public function setData(Event $event)
 {
     $paginator = $event->getParam('paginator');
     if ($paginator instanceof Paginator) {
         $controller = $event->getTarget();
         $paginator->setData($controller->params()->fromQuery());
     }
 }
开发者ID:nicovogelaar,项目名称:paginator-module,代码行数:15,代码来源:CrudControllerListener.php


示例12: addPages

 /**
  * @param Event $e
  */
 public function addPages(Event $e)
 {
     $this->event = $e;
     $pages = $this->getPages();
     // find parent page
     $parentPage = $this->getNavigation()->findOneByRoute($this->getRoute());
     // add pages to parent
     $parentPage->addPages($e->getTarget()->preparePages($pages));
 }
开发者ID:uthando-cms,项目名称:uthando-navigation,代码行数:12,代码来源:AbstractSiteMapListener.php


示例13: ligar

 public function ligar(Event $objEvent)
 {
     $this->sn_luz_ligada = true;
     echo "A luz está ligada";
     echo "<BR>";
     echo "O alarme foi disparado por: ";
     echo $objEvent->getTarget()->getNome();
     return $this;
 }
开发者ID:adrwtr,项目名称:ZendExemplos,代码行数:9,代码来源:Luz.php


示例14: onBootstrap

 /**
  * onBootstrap
  * @param MvcEvent $e
  */
 public function onBootstrap(Event $e)
 {
     $application = $e->getTarget();
     $serviceManager = $application->getServiceManager();
     $eventManager = $application->getEventManager();
     // set static adapter for all module table gateways
     $dbAdapter = $serviceManager->get('Zend\\Db\\Adapter\\Adapter');
     Feature\GlobalAdapterFeature::setStaticAdapter($dbAdapter);
 }
开发者ID:remithomas,项目名称:rt-object,代码行数:13,代码来源:Module.php


示例15: onUpdate

 /**
  * Gets executed on page create
  *
  * @param Event $e
  * @return void
  */
 public function onUpdate(Event $e)
 {
     /* @var $repository PageRepositoryInterface */
     $slug = $e->getParam('slug');
     $repository = $e->getParam('repository');
     $url = $e->getTarget()->url()->fromRoute('page/view', ['page' => $repository->getId()], null, null, false);
     $alias = $this->getAliasManager()->createAlias($url, $slug, $slug . '-' . $repository->getId(), $repository, $repository->getInstance());
     $this->getAliasManager()->flush($alias);
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:15,代码来源:PageControllerListener.php


示例16: validateContent

 /**
  * Validate and Filter content passed to the Resource
  *
  * By default this will prevent XSS and malicious
  * code being passed to the backend.
  *
  * Further event propagation is stopped to prevent
  * additional manipulation to reduce further risk.
  *
  * @param Event $event
  * @return array|null
  */
 public function validateContent(Event $event)
 {
     $controller = $event->getTarget();
     if ($controller instanceof ResourceController) {
         $request = $event->getTarget()->getRequest();
         if (!$request instanceof HttpRequest) {
             return;
         }
         if (in_array($request->getMethod(), $this->methodsWithoutBodies)) {
             return;
         }
         $resource = $controller->getResource();
         if ($resource instanceof Resource) {
             /**
              * Check Request method is allowed by Resource
              * Usually this would be picked up by Access Control,
              * however we should always check
              */
             if (!in_array($request->getMethod(), $resource->getResourceHttpMethods())) {
                 return;
             }
             $inputFilter = $resource->getInputFilter();
             if (!$inputFilter instanceof InputFilter) {
                 return;
             }
             try {
                 $data = $event->getParam('data', array());
                 if ($request->isPatch()) {
                     // Only filter values that have been provided
                     $inputFilter->setValidationGroup(array_keys($data));
                 }
                 $inputFilter->setData($data);
                 if ($inputFilter->isValid()) {
                     $filteredData = $inputFilter->getValues();
                     $event->stopPropagation(true);
                     return array_merge($data, $filteredData);
                 }
                 return new ProblemResponse(new Problem(422, 'Failed Validation', null, null, ['validation_messages' => $inputFilter->getMessages()]));
             } catch (\Exception $ex) {
                 return new ProblemResponse(new Problem(400, 'Invalid data specified in request'));
             }
         }
     }
 }
开发者ID:parrotcage,项目名称:aves,代码行数:56,代码来源:ContentValidationListener.php


示例17: addPages

 public function addPages(Event $e)
 {
     /* @var \Zend\Navigation\Navigation $navigation */
     $navigation = $e->getParam('navigation');
     /* @var \UthandoNews\Service\News $newsService */
     $newsService = $e->getTarget()->getService('UthandoNews');
     /* @var \UthandoNavigation\Service\Menu $menuService */
     $menuService = $e->getTarget()->getService('UthandoNavigationMenu');
     $newsItems = $newsService->search(['sort' => '-dateCreated']);
     $pages = [];
     /* @var \UthandoNews\Model\News $newsItem */
     foreach ($newsItems as $newsItem) {
         $pages[$newsItem->getArticle()->getSlug()] = ['label' => $newsItem->getArticle()->getTitle(), 'route' => 'news', 'params' => ['news-item' => $newsItem->getArticle()->getSlug()]];
     }
     // find shop page
     $newsPage = $navigation->findOneByRoute('news-list');
     // add categories to shop page
     $newsPage->addPages($menuService->preparePages($pages));
 }
开发者ID:uthando-cms,项目名称:uthando-news,代码行数:19,代码来源:SiteMapListener.php


示例18: preSend

 /**
  * Add Client Id and Client Secret to Request Parameters
  *
  * @throws Exception\InvalidArgumentException
  */
 public function preSend(Event $e)
 {
     $validator = new NotEmpty();
     if (!array_key_exists('client_id', $this->options) || !$validator->isValid($this->options['client_id'])) {
         throw new Exception\InvalidArgumentException('You need to set client_id!');
     }
     $request = $e->getTarget();
     $query = $request->getQuery();
     $query->set('client_id', $this->options['client_id']);
 }
开发者ID:hounddog,项目名称:hd-instagram,代码行数:15,代码来源:UrlClientId.php


示例19: tocar

 public function tocar(Event $objEvent)
 {
     echo "<HR>";
     echo "A buzina está tocando";
     echo "<BR>";
     echo "O alarme foi disparado por: ";
     echo $objEvent->getTarget()->getNome();
     $objEvent->stopPropagation(true);
     return $this;
 }
开发者ID:adrwtr,项目名称:ZendExemplos,代码行数:10,代码来源:Buzina.php


示例20: preSend

 /**
  * Add access token to Request Parameters
  *
  * @throws Exception\InvalidArgumentException
  */
 public function preSend(Event $e)
 {
     $validator = new NotEmpty();
     if (!isset($this->options['tokenOrLogin']) || !$validator->isValid($this->options['tokenOrLogin'])) {
         throw new Exception\InvalidArgumentException('You need to set OAuth token!');
     }
     $request = $e->getTarget();
     $query = $request->getQuery();
     $query->set('access_token', $this->options['tokenOrLogin']);
 }
开发者ID:hounddog,项目名称:hd-api-client,代码行数:15,代码来源:UrlToken.php



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