PHP code example of wwwision / node-event-log

1. Go to this page and download the library: Download wwwision/node-event-log library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wwwision / node-event-log example snippets


$recursively = true;
$filter = EventLogFilter::create()
    ->forNode(NodeAggregateIdentifier::fromString('some-node-id'), $recursively)
    ->inContentStream(ContentStreamIdentifier::fromString('some-content-stream-id'))
    ->forInitiatingUser(UserIdentifier::fromString('some-user-id'))
    ->skipInheritedEvents();

$result = $this->eventLog->filter(EventLogFilter::create());
echo 'Total number of results: ' . $result->count() . PHP_EOL;
/** @var NodeEvent $event */
foreach ($result->first(5)->toNodeArray() as $event) {
    echo $event->eventType() . PHP_EOL;
}

$result = $this->eventLog->filter(EventLogFilter::create())->reversed();
$after = null;
do {
    $page = $result->first(3, $after);
    foreach ($page as $edge) {
        /** @var NodeEvent $event */
        $event = $edge->node();
        echo $event->id() . PHP_EOL;
    }
    echo '----' . PHP_EOL;
    $after = $page->pageInfo()->endCursor();
} while ($page->pageInfo()->hasNextPage());

$result = $this->eventLog->filter(EventLogFilter::create())
    ->withNodeConverter(fn(array $event) => $event['id']);
echo implode(',', $result->first(10)->toNodeArray());