From d5d882c9bed61010d6a529e6a0246ede9a3652da Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Mon, 28 Jan 2019 09:24:41 -0500 Subject: [PATCH] Implement method to set up the activity event handling pipeline --- src/ActivityPub.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/ActivityPub.php b/src/ActivityPub.php index 667febb..cb8b9cc 100644 --- a/src/ActivityPub.php +++ b/src/ActivityPub.php @@ -3,6 +3,8 @@ namespace ActivityPub; require_once __DIR__ . '/../vendor/autoload.php'; +use ActivityPub\Activities\NonActivityHandler; +use ActivityPub\Activities\ValidationHandler; use ActivityPub\Auth\AuthListener; use ActivityPub\Auth\SignatureListener; use ActivityPub\Config\ActivityPubConfig; @@ -55,6 +57,8 @@ class ActivityPub $dispatcher->addSubscriber( $this->module->get( SignatureListener::class ) ); $dispatcher->addSubscriber( new ExceptionListener() ); + $this->subscribeActivityHandler( $dispatcher ); + $controllerResolver = new ControllerResolver(); $argumentResolver = new ArgumentResolver(); @@ -64,6 +68,13 @@ class ActivityPub return $kernel->handle( $request ); } + /** + * Creates the database tables necessary for the library to function, + * if they have not already been created. + * + * For best performance, this should only get called once in an application + * (for example, when other database migrations get run). + */ public function updateSchema() { $entityManager = $this->module->get( EntityManager::class ); @@ -71,5 +82,17 @@ class ActivityPub $classes = $entityManager->getMetadataFactory()->getAllMetadata(); $schemaTool->updateSchema( $classes ); } + + /** + * Sets up the activity handling pipeline + * + * @param EventDispatcher $dispatcher The dispatcher to attach the event + * subscribers to + */ + private function subscribeActivityHandlers( EventDispatcher $dispatcher ) + { + $dispatcher->addSubscriber( $this->module->get( NonActivityHandler::class ) ); + $dispatcher->addSubscriber( $this->module->get( ValidationHandler::class ) ); + } } ?>