TAO-Core observer implementations. They support native PHP SplObserver and SplSubject.
Used in case you want to notify the subject for logging purposes.
$observer = new \oat\tao\model\Observer\Log\LoggerObserver($logger);
$anySubject = new \oat\tao\model\Observer\Subject(
[
'some' => 'data',
'another' => 'data',
]
)
$anySubject->attach($observer);
$anySubject->notify(); // Will log subject data...
Used in case you want to notify GCP Pub/Sub
service.
Requirements:
Install GCP lib:
php composer.phar require "google/cloud-pubsub":"1.34.*" -vvv
$factory = (new \oat\tao\model\Observer\GCP\PubSubClientFactory())->create();
$observer = new \oat\tao\model\Observer\GCP\PubSubObserver(
$client,
$logger,
[
\oat\tao\model\Observer\GCP\PubSubObserver::CONFIG_TOPIC => 'my_gcp_topic',
]
);
$anySubject = new \oat\tao\model\Observer\Subject(
[
'some' => 'data',
'another' => 'data',
]
);
$anySubject->attach($observer);
$anySubject->notify(); // Will send a message to GCP Pub/Sub