PHP 8.3.31
Preview: observer.php Size: 1.09 KB
/proc/self/root/opt/alt/tests/alt-php85-pecl-mongodb_2.3.1-1.el8/utils/observer.php

<?php
use MongoDB\Driver\Monitoring\CommandFailedEvent;
use MongoDB\Driver\Monitoring\CommandStartedEvent;
use MongoDB\Driver\Monitoring\CommandSucceededEvent;
use MongoDB\Driver\Monitoring\CommandSubscriber;
/**
 * Observes command documents using the driver's monitoring API.
 */
class CommandObserver implements CommandSubscriber
{
    private $commands = [];
    public function observe(callable $execution, callable $commandCallback)
    {
        $this->commands = [];
        \MongoDB\Driver\Monitoring\addSubscriber($this);
        try {
            call_user_func($execution);
        } finally {
            \MongoDB\Driver\Monitoring\removeSubscriber($this);
            foreach ($this->commands as $command) {
                call_user_func($commandCallback, $command);
            }
        }
    }
    public function commandStarted(CommandStartedEvent $event): void
    {
        $this->commands[] = $event->getCommand();
    }
    public function commandSucceeded(CommandSucceededEvent $event): void
    {
    }
    public function commandFailed(CommandFailedEvent $event): void
    {
    }
}
?>

Directory Contents

Dirs: 0 × Files: 7

Name Size Perms Modified Actions
795 B lrw-r--r-- 2026-05-18 14:35:45
Edit Download
855 B lrw-r--r-- 2026-05-18 14:35:45
Edit Download
1.55 KB lrw-r--r-- 2026-05-18 14:35:45
Edit Download
1.09 KB lrw-r--r-- 2026-05-18 14:35:45
Edit Download
73.94 KB lrw-r--r-- 2026-05-18 14:35:45
Edit Download
12.44 KB lrw-r--r-- 2026-05-18 14:35:45
Edit Download
24.22 KB lrw-r--r-- 2026-05-18 14:35:45
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).