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


PHP Event::getResourceIdList方法代码示例

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


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

示例1: onEvent

 /**
  * Handle any event
  *
  * If this method does not fit to your need, you are advised to extend this
  * class and modify this method to suit your own needs
  *
  * @param string $resourceType
  * @param string $action
  * @param Event $event
  */
 protected function onEvent($resourceType, $action, Event $event)
 {
     $idList = null;
     $data = null;
     $key = $resourceType . ':' . $action;
     $sendOnDefaultChan = true;
     $additionalChanId = [];
     if ($event instanceof ResourceEvent) {
         $data = $event->getArguments();
         $idList = $event->getResourceIdList();
         $additionalChanId = $event->getChanIdList();
         $sendOnDefaultChan = $event->shouldKeepDefaultChan();
     } else {
         if ($event instanceof GenericEvent) {
             $data = $event->getArguments();
             // Attempt to do a best guess at the resource identifier
             if (isset($event['id'])) {
                 $idList = [$event['id']];
             } else {
                 $subject = $event->getSubject();
                 if (is_scalar($subject)) {
                     $idList = [$subject];
                 } else {
                     if (method_exists($subject, 'getId')) {
                         $idList = [$subject->getId()];
                     } else {
                         if (property_exists($subject, 'id')) {
                             $idList = [$subject->id];
                         }
                     }
                 }
             }
         }
     }
     if (isset($idList)) {
         // Proceed with pre-configured overrides
         if ($sendOnDefaultChan && isset($this->chanBlockingOverrides[$key])) {
             $additionalChanId = array_merge($additionalChanId, $this->chanBlockingOverrides[$key]);
             // FIXME override should not be blocking default chans
             // @TODO add a blocking boolean tag attribute (false by default)
             // $sendOnDefaultChan = false;
         }
         if ($additionalChanId) {
             foreach ($idList as $id) {
                 if ($sendOnDefaultChan) {
                     $additionalChanId[] = $this->service->getChanId($resourceType, $id);
                 }
                 $this->service->notifyChannel($additionalChanId, $resourceType, $id, $action, $data);
             }
         } else {
             if ($sendOnDefaultChan) {
                 foreach ($idList as $id) {
                     $this->service->notify($resourceType, $id, $action, $data);
                 }
             }
         }
         // We might end up sending nothing, as soon as any of the listeners
         // explicitly forbid to send on the default chan, and we have no
         // additional chans.
     }
 }
开发者ID:makinacorpus,项目名称:apubsub,代码行数:71,代码来源:AutoEventListener.php


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