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

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

Add a notification event to the queue
public enqueueEvent ( string $action, string $type, ElggDat\ElggData $object ) : void
$action string Action name
$type string Type of the object of the action
$object ElggDat\ElggData The object of the action
Результат void
    public function enqueueEvent($action, $type, $object)
    {
        if ($object instanceof ElggData) {
            $object_type = $object->getType();
            $object_subtype = $object->getSubtype();
            $registered = false;
            if (!empty($this->events[$object_type][$object_subtype]) && in_array($action, $this->events[$object_type][$object_subtype])) {
                $registered = true;
            }
            if ($registered) {
                $params = array('action' => $action, 'object' => $object);
                $registered = $this->hooks->trigger('enqueue', 'notification', $params, $registered);
            }
            if ($registered) {
                $this->queue->enqueue(new SubscriptionNotificationEvent($object, $action));
            }
        }
    }

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));
 }