Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Developer Documentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
brienne
Developer Documentation
Commits
a577d98f
Commit
a577d98f
authored
7 years ago
by
totten
Browse files
Options
Downloads
Patches
Plain Diff
symfony.md - Copy edits
parent
243e2283
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/hooks/setup/symfony.md
+12
-13
12 additions, 13 deletions
docs/hooks/setup/symfony.md
with
12 additions
and
13 deletions
docs/hooks/setup/symfony.md
+
12
−
13
View file @
a577d98f
## 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 d
ocumentation for
have focused on the simplest one,
`addListener()`
, but you can find d
iscussion 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,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment