From a577d98faa92a1fb83d01ac283c75cb47d906f37 Mon Sep 17 00:00:00 2001 From: Tim Otten <totten@civicrm.org> Date: Tue, 30 May 2017 16:20:21 -0700 Subject: [PATCH] symfony.md - Copy edits --- docs/hooks/setup/symfony.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/docs/hooks/setup/symfony.md b/docs/hooks/setup/symfony.md index 4f1decc2..b93e724b 100644 --- a/docs/hooks/setup/symfony.md +++ b/docs/hooks/setup/symfony.md @@ -1,9 +1,10 @@ ## Overview -The [__Symfony EventDispatcher__](http://symfony.com/components/EventDispatcher) is a -common event system used by many PHP applications and frameworks. For -example, Symfony SE, Drupal 8, Magento, Laravel, CiviCRM, and many others -support `EventDispatcher`. +The [__Symfony EventDispatcher__](http://symfony.com/components/EventDispatcher) is an +event library used by several PHP applications and frameworks. For example, +Symfony SE, Drupal 8, Magento, Laravel, CiviCRM, and many others support +`EventDispatcher`. It provides a common mechanism for dispatching and listening +to events. In CiviCRM v4.7.19+, you can use Symfony `EventDispatcher` with hooks. @@ -76,9 +77,9 @@ events fall into two categories: Hooks are simulcast across `EventDispatcher` as well as CMS-specific event systems. * __Internal Events__ (v4.5.0+): These have a prefix `civi.*`. They extend the class [`Event`](http://api.symfony.com/2.7/Symfony/Component/EventDispatcher/Event.html). + They are *only* broadcast via `EventDispatcher` (**not** CMS-specific event systems). -The dispatch process is largely the same for private and public events. However, -you can recognize these events by their naming convention. Compare: +You can recognize these events by their naming convention. Compare: ```php // Listen to a hook. Note the prefix, "hook_civicrm_*". @@ -91,9 +92,12 @@ Civi::dispatcher()->addListener('civi.api.resolve', $callback, $priority); ## Methods The `EventDispatcher` has several different methods for registering a listener. Our examples -have focused on the simplest one, `addListener()`, but you can find documentation for +have focused on the simplest one, `addListener()`, but you can find discussion of the other methods (`addSubscriber()`, `addListenerService()`, and `addSubscriberService()`) -in the Symfony documentation. +in the Symfony documentation: + + * [Symfony EventDispatcher](http://symfony.com/doc/2.7/components/event_dispatcher.html) + * [Symfony ContainerAwareEventDispatcher](http://symfony.com/doc/2.7/components/event_dispatcher/container_aware_dispatcher.html) !!! tip When calling `addListener()`, you can pass any [PHP callable](http://php.net/manual/en/language.types.callable.php). @@ -101,11 +105,6 @@ in the Symfony documentation. (class-name, function-name). Other formats may not work with the [container-cache](http://symfony.com/doc/2.7/components/dependency_injection/compilation.html). -!!! seealso - * [Symfony EventDispatcher](http://symfony.com/doc/2.7/components/event_dispatcher.html) - * [Symfony ContainerAwareEventDispatcher](http://symfony.com/doc/2.7/components/event_dispatcher/container_aware_dispatcher.html) - - ## History * _CiviCRM v4.5.0_: Introduced Symfony EventDispatcher for internal use (within `civicrm-core`). For example, -- GitLab