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


PHP Event::name方法代码示例

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


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

示例1: authCheck

 public function authCheck(Event $event)
 {
     if (isset($this->earlyAuthTest)) {
         if ($this->_config['checkAuthIn'] !== $event->name()) {
             return;
         }
         $this->authCheckCalledFrom = $event->name();
         return;
     }
     return parent::authCheck($event);
 }
开发者ID:Slayug,项目名称:castor,代码行数:11,代码来源:TestAuthComponent.php

示例2: afterRules

 public function afterRules(Cake\Event\Event $event, Cat $entity, \ArrayObject $options, $result, $operation)
 {
     Log::write("debug", "afterRules");
     Log::write("debug", $event->name());
     Log::write("debug", "entity " . $entity);
     Log::write("debug", $options);
     Log::write("debug", "result " . $result);
     Log::write("debug", "operation " . $operation);
 }
开发者ID:jeffblack360,项目名称:cakeblog,代码行数:9,代码来源:CatsTable.php

示例3: handleEvent

 /**
  * There is only one event handler, it can be configured to be called for any event
  *
  * @param \Cake\Event\Event $event Event instance.
  * @param \Cake\Datasource\EntityInterface $entity Entity instance.
  * @throws \UnexpectedValueException if a field's when value is misdefined
  * @return true (irrespective of the behavior logic, the save will not be prevented)
  * @throws \UnexpectedValueException When the value for an event is not 'always', 'new' or 'existing'
  */
 public function handleEvent(Event $event, EntityInterface $entity)
 {
     $eventName = $event->name();
     $events = $this->_config['events'];
     if ($events[$eventName] === true) {
         $this->_purify($entity);
     }
     return true;
 }
开发者ID:adamharley,项目名称:CakePHP3-HtmlPurifier,代码行数:18,代码来源:HtmlPurifierBehavior.php

示例4: footprint

 /**
  * Try and attach footprint listener to models.
  *
  * It also passing the user record to footprint listener after user is
  * identified by AuthComponent.
  *
  * @param \Cake\Event\Event $event Event.
  * @return void
  */
 public function footprint(Event $event)
 {
     if (!$this->_listener) {
         $this->_listener = new FootprintListener($this->_getCurrentUser());
     }
     if ($event->name() === 'Auth.afterIdentify') {
         $this->_listener->setUser($this->_getCurrentUser($event->data));
         return;
     }
     $event->subject()->eventManager()->attach($this->_listener);
 }
开发者ID:Adnan0703,项目名称:Footprint,代码行数:20,代码来源:FootprintAwareTrait.php

示例5: handleEvent

 /**
  * There is only one event handler, it can be configured to be called for any event
  *
  * @param \Cake\Event\Event $event Event instance.
  * @param \Cake\ORM\Entity $entity Entity instance.
  * @throws \UnexpectedValueException if a field's when value is misdefined
  * @return true (irrespective of the behavior logic, the save will not be prevented)
  * @throws \UnexpectedValueException When the value for an event is not 'always', 'new' or 'existing'
  */
 public function handleEvent(Event $event, Entity $entity)
 {
     $eventName = $event->name();
     $events = $this->config('events');
     $new = $entity->isNew() !== false;
     foreach ($events[$eventName] as $field => $when) {
         if (!in_array($when, ['always', 'new', 'existing'])) {
             throw new \UnexpectedValueException(sprintf('When should be one of "always", "new" or "existing". The passed value "%s" is invalid', $when));
         }
         if ($when === 'always' || $when === 'new' && $new || $when === 'existing' && !$new) {
             $this->_updateField($entity, $field);
         }
     }
     return true;
 }
开发者ID:Aerue,项目名称:cakephp-blame,代码行数:24,代码来源:BlameBehavior.php

示例6: beforeSave

 /**
  * Injects configured field values into entity if those fields are not dirty.
  *
  * @param \Cake\Event\Event $event Event.
  * @param \Cake\ORM\Entity $entity Entity.
  * @param \ArrayObject $options Options.
  * @return void
  */
 public function beforeSave(Event $event, Entity $entity, ArrayObject $options)
 {
     $eventName = $event->name();
     $events = $this->config('events');
     $new = $entity->isNew() !== false;
     foreach ($events[$eventName] as $field => $when) {
         if (!in_array($when, ['always', 'new', 'existing'])) {
             throw new UnexpectedValueException(sprintf('When should be one of "always", "new" or "existing". The passed value "%s" is invalid', $when));
         }
         if ($entity->dirty($field)) {
             continue;
         }
         if ($when === 'always' || $when === 'new' && $new || $when === 'existing' && !$new) {
             $entity->set($field, current(Hash::extract((array) $options, $this->config('propertiesMap.' . $field))));
         }
     }
 }
开发者ID:Adnan0703,项目名称:Footprint,代码行数:25,代码来源:FootprintBehavior.php

示例7: onView

 /**
  * @param Event $event
  * @return string
  */
 public function onView(Event $event)
 {
     return $event->name();
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:8,代码来源:SimpleEventHandler.php

示例8: authCheck

 /**
  * Main execution method, handles initial authentication check and redirection
  * of invalid users.
  *
  * The auth check is done when event name is same as the one configured in
  * `checkAuthIn` config.
  *
  * @param \Cake\Event\Event $event Event instance.
  * @return \Cake\Network\Response|null
  */
 public function authCheck(Event $event)
 {
     if ($this->_config['checkAuthIn'] !== $event->name()) {
         return null;
     }
     $controller = $event->subject();
     $action = strtolower($controller->request->params['action']);
     if (!$controller->isAction($action)) {
         return null;
     }
     $this->_setDefaults();
     if ($this->_isAllowed($controller)) {
         return null;
     }
     $isLoginAction = $this->_isLoginAction($controller);
     if (!$this->_getUser()) {
         if ($isLoginAction) {
             return null;
         }
         $result = $this->_unauthenticated($controller);
         if ($result instanceof Response) {
             $event->stopPropagation();
         }
         return $result;
     }
     if ($isLoginAction || empty($this->_config['authorize']) || $this->isAuthorized($this->user())) {
         return null;
     }
     $event->stopPropagation();
     return $this->_unauthorized($controller);
 }
开发者ID:MillHidden,项目名称:BiellesMeusiennes,代码行数:41,代码来源:AuthComponent.php

示例9: dispatch

 /**
  * Dispatches a new event to all configured listeners
  *
  * @param string|\Cake\Event\Event $event the event key name or instance of Event
  * @return \Cake\Event\Event
  * @triggers $event
  */
 public function dispatch($event)
 {
     if (is_string($event)) {
         $event = new Event($event);
     }
     $listeners = $this->listeners($event->name());
     if (empty($listeners)) {
         return $event;
     }
     foreach ($listeners as $listener) {
         if ($event->isStopped()) {
             break;
         }
         $result = $this->_callListener($listener['callable'], $event);
         if ($result === false) {
             $event->stopPropagation();
         }
         if ($result !== null) {
             $event->result = $result;
         }
     }
     return $event;
 }
开发者ID:ansidev,项目名称:cakephp_blog,代码行数:30,代码来源:EventManager.php

示例10: handle

 /**
  * Handler method that applies conditions and resolves the correct method to call.
  *
  * @param \Cake\Event\Event $event The event instance.
  * @return mixed
  */
 public function handle(Event $event)
 {
     $name = $event->name();
     list(, $method) = explode('.', $name);
     if (empty($this->_config['for']) && empty($this->_config['when'])) {
         return $this->{$method}($event);
     }
     if ($this->matches($event)) {
         return $this->{$method}($event);
     }
 }
开发者ID:rlugojr,项目名称:cakephp,代码行数:17,代码来源:DispatcherFilter.php

示例11: dispatch

 /**
  * Dispatches a new event to all configured listeners
  *
  * @param string|\Cake\Event\Event $event the event key name or instance of Event
  * @return \Cake\Event\Event
  * @triggers $event
  */
 public function dispatch($event)
 {
     if (is_string($event)) {
         $event = new Event($event);
     }
     $listeners = $this->listeners($event->name());
     if ($this->_trackEvents) {
         $this->addEventToList($event);
     }
     if (!$this->_isGlobal && static::instance()->isTrackingEvents()) {
         static::instance()->addEventToList($event);
     }
     if (empty($listeners)) {
         return $event;
     }
     foreach ($listeners as $listener) {
         if ($event->isStopped()) {
             break;
         }
         $result = $this->_callListener($listener['callable'], $event);
         if ($result === false) {
             $event->stopPropagation();
         }
         if ($result !== null) {
             $event->result = $result;
         }
     }
     return $event;
 }
开发者ID:nrother,项目名称:cakephp,代码行数:36,代码来源:EventManager.php

示例12: testName

 /**
  * Tests the name() method
  *
  * @return void
  * @triggers fake.event
  */
 public function testName()
 {
     $event = new Event('fake.event');
     $this->assertEquals('fake.event', $event->name());
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:11,代码来源:EventTest.php

示例13: filterTest

 /**
  * Helper function to test single method attaching for dispatcher filters
  *
  * @param \Cake\Event\Event $event
  * @return void
  */
 public function filterTest($event)
 {
     $event->data['request']->params['eventName'] = $event->name();
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:10,代码来源:DispatcherTest.php


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