Elgg\Notifications\NotificationsService::registerEvent PHP Метод

registerEvent() публичный Метод

См. также: elgg_register_notification_event()
public registerEvent ( $type, $subtype, array $actions = [] )
$actions array
    public function registerEvent($type, $subtype, array $actions = array())
    {
        if (!isset($this->events[$type])) {
            $this->events[$type] = array();
        }
        if (!isset($this->events[$type][$subtype])) {
            $this->events[$type][$subtype] = array();
        }
        $action_list =& $this->events[$type][$subtype];
        if ($actions) {
            $action_list = array_unique(array_merge($action_list, $actions));
        } elseif (!in_array('create', $action_list)) {
            $action_list[] = 'create';
        }
    }

Usage Example

Пример #1
0
 public function testValidatesActorExistenceForDequeuedSubscriptionNotificationEvent()
 {
     // This test can be enabled once users table operations such as delete/ban are mocked
     $this->markTestSkipped();
     $object = $this->getTestObject();
     $mock = $this->getMock(SubscriptionsService::class, ['getSubscriptions'], [], '', false);
     $mock->expects($this->exactly(0))->method('getSubscriptions')->will($this->returnValue([]));
     $this->subscriptions = $mock;
     $this->setupServices();
     $this->notifications->registerMethod('test_method');
     $this->session->setLoggedInUser($this->actor);
     $this->notifications->registerEvent($object->getType(), $object->getSubtype(), ['test_event']);
     $this->notifications->enqueueEvent('test_event', $object->getType(), $object);
     $this->session->removeLoggedInUser();
     $actor->delete();
     $this->assertEquals(0, $this->notifications->processQueue($this->time + 10));
 }