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


PHP Event::setName方法代码示例

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


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

示例1: createAnnotation

 /**
  * Create Annotation
  *
  * @param  array $annotationData
  * @return false|\stdClass
  */
 public function createAnnotation(array $annotationData)
 {
     $event = new Event();
     $event->setName(self::EVENT_CREATE_ANNOTATION);
     $event->setTarget($this);
     $event->setParams(array('class' => $annotationData[0], 'content' => $annotationData[1], 'raw' => $annotationData[2]));
     $results = $this->getEventManager()->trigger($event, function ($r) {
         return is_object($r);
     });
     $annotation = $results->last();
     return is_object($annotation) ? $annotation : false;
 }
开发者ID:Baft,项目名称:Zend-Form,代码行数:18,代码来源:AnnotationManager.php

示例2: triggerEvent

 /**
  * Triggers the specified event on the defined context and return a concateneted string with the results
  * @param string $eventName
  * @param mixed $target
  * @param array $argv
  * @return string
  */
 public function triggerEvent($eventName, $target, $argv)
 {
     //init the event with the target, params and name
     $event = new Event();
     $event->setTarget($target);
     $event->setParams($argv);
     $event->setName($eventName);
     $content = "";
     //trigger the event listeners
     $responses = $this->events()->trigger($eventName, $event);
     //merge all results and return the response
     foreach ($responses as $response) {
         $content .= $response;
     }
     return $content;
 }
开发者ID:rikaix,项目名称:ZeTwig,代码行数:23,代码来源:Extension.php

示例3: testEventListenerIsAttached

 public function testEventListenerIsAttached()
 {
     $module = new Module();
     $mvcEvent = $this->getMock('Zend\\EventManager\\EventInterface');
     $application = $this->getMock('Zend\\Mvc\\Application', [], [], '', false);
     $eventManager = new EventManager();
     $eventManager->setSharedManager(new SharedEventManager());
     $serviceManager = new ServiceManager();
     $mvcEvent->expects($this->once())->method('getParam')->with('application')->will($this->returnValue($application));
     $application->expects($this->once())->method('getEventManager')->will($this->returnValue($eventManager));
     $application->expects($this->once())->method('getServiceManager')->will($this->returnValue($serviceManager));
     $eventManager->addIdentifiers(['ZfcUser\\Service\\User']);
     $event = new Event();
     $event->setName('register.post');
     $userRegistrationService = $this->getMock('HtUserRegistration\\Service\\UserRegistrationServiceInterface');
     $serviceManager->setService('HtUserRegistration\\UserRegistrationService', $userRegistrationService);
     $userRegistrationService->expects($this->once())->method('onUserRegistration')->with($event);
     $module->onBootstrap($mvcEvent);
     $eventManager->trigger($event);
 }
开发者ID:Ellipizle,项目名称:HtUserRegistration,代码行数:20,代码来源:ModuleTest.php

示例4: __invoke

 /**
  * Triggers the specified event on the defined context and return a concateneted string with the results
  *
  * @param string $eventName
  * @param mixed $target
  * @param array $argv
  * @return string
  */
 public function __invoke($eventName, $target, $argv)
 {
     $alias = 'zfc-twig';
     if (strpos($eventName, ':') !== false) {
         $aux = explode(':', $eventName);
         $alias = $aux[0];
         $eventName = $aux[1];
     }
     //init the event with the target, params and name
     $event = new Event();
     $event->setTarget($target);
     $event->setParams($argv);
     $event->setName($eventName);
     $content = "";
     //trigger the event listeners
     $responses = $this->events($alias)->trigger($eventName, $event);
     //merge all results and return the response
     foreach ($responses as $response) {
         $content .= $response;
     }
     return $content;
 }
开发者ID:2eye-studios,项目名称:development,代码行数:30,代码来源:Trigger.php

示例5: testTriggerCanTakeAnOptionalCallbackArgumentToEmulateTriggerUntil

 public function testTriggerCanTakeAnOptionalCallbackArgumentToEmulateTriggerUntil()
 {
     $this->events->attach(__FUNCTION__, function ($e) {
         return $e;
     });
     // Four scenarios:
     // First: normal signature:
     $responses = $this->events->trigger(__FUNCTION__, $this, array(), function ($r) {
         return $r instanceof EventInterface;
     });
     $this->assertTrue($responses->stopped());
     // Second: Event as $argv parameter:
     $event = new Event();
     $responses = $this->events->trigger(__FUNCTION__, $this, $event, function ($r) {
         return $r instanceof EventInterface;
     });
     $this->assertTrue($responses->stopped());
     // Third: Event as $target parameter:
     $event = new Event();
     $event->setTarget($this);
     $responses = $this->events->trigger(__FUNCTION__, $event, function ($r) {
         return $r instanceof EventInterface;
     });
     $this->assertTrue($responses->stopped());
     // Fourth: Event as $event parameter:
     $event = new Event();
     $event->setTarget($this);
     $event->setName(__FUNCTION__);
     $responses = $this->events->trigger($event, function ($r) {
         return $r instanceof EventInterface;
     });
     $this->assertTrue($responses->stopped());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:33,代码来源:EventManagerTest.php

示例6: isValid

 /**
  * Is this session valid?
  *
  * Notifies the Validator Chain until either all validators have returned
  * true or one has failed.
  *
  * @return bool
  */
 public function isValid()
 {
     $validator = $this->getValidatorChain();
     $event = new Event();
     $event->setName('session.validate');
     $event->setTarget($this);
     $event->setParams($this);
     $falseResult = function ($test) {
         return false === $test;
     };
     $responses = $validator->triggerEventUntil($falseResult, $event);
     if ($responses->stopped()) {
         // If execution was halted, validation failed
         return false;
     }
     // Otherwise, we're good to go
     return true;
 }
开发者ID:zendframework,项目名称:zend-session,代码行数:26,代码来源:SessionManager.php

示例7: checkForExclude

 /**
  * Determine if an element is marked to exclude from the definitions
  *
  * @param  AnnotationCollection $annotations
  * @return true|false
  */
 protected function checkForExclude($annotations)
 {
     $event = new Event();
     $event->setName(__FUNCTION__);
     $event->setTarget($this);
     $event->setParams(['annotations' => $annotations]);
     $results = $this->getEventManager()->triggerEventUntil(function ($r) {
         return true === $r;
     }, $event);
     return (bool) $results->last();
 }
开发者ID:vbryan,项目名称:Zend,代码行数:17,代码来源:AnnotationBuilder.php

示例8: setName

 /**
  * setName
  *
  * Set the name of the event that should be triggered.
  *
  * @param  string  $name  The name of the event.
  *
  * @return $this
  */
 public function setName($name)
 {
     return parent::setName($name);
 }
开发者ID:alex-patterson-webdev,项目名称:arp-auth,代码行数:13,代码来源:AuthenticationEvent.php

示例9: parsePage

 /**
  * Parse a single page into a navigation configuration
  *
  * @param  Page $page
  * @return array
  * @throws Exception\RuntimeException
  */
 public function parsePage(PageInterface $page)
 {
     $meta = $page->getMetaData();
     $navPage = Page::factory(array('type' => 'mvc', 'route' => (string) $page->getId(), 'label' => $meta->getNavigationTitle(), 'visible' => $page->isVisible()));
     $event = new Event();
     $event->setName(__FUNCTION__ . '.' . $page->getModule());
     $event->setTarget($this);
     $event->setParams(array('page' => $page, 'navigation' => $navPage));
     $this->events->trigger($event);
     return $navPage;
 }
开发者ID:i-MSCP,项目名称:EnsembleKernel,代码行数:18,代码来源:Navigation.php


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