Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
192 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Ivory Serializer bundle package. | ||
* | ||
* (c) Eric GELOEN <geloen.eric@gmail.com> | ||
* | ||
* For the full copyright and license information, please read the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Ivory\SerializerBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass as AbstractRegisterListenerPass; | ||
|
||
/** | ||
* @author GeLo <geloen.eric@gmail.com> | ||
*/ | ||
class RegisterListenerPass extends AbstractRegisterListenerPass | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct( | ||
'ivory.serializer.event.dispatcher', | ||
'ivory.serializer.listener', | ||
'ivory.serializer.subscriber' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<container | ||
xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services | ||
http://symfony.com/schema/dic/services/services-1.0.xsd" | ||
> | ||
<services> | ||
<service | ||
id="ivory.serializer.event.dispatcher" | ||
class="Symfony\Component\EventDispatcher\EventDispatcher" | ||
/> | ||
|
||
<service | ||
id="ivory.serializer.mapping.factory.event" | ||
class="Ivory\Serializer\Mapping\Factory\EventClassMetadataFactory" | ||
> | ||
<argument type="service" id="ivory.serializer.mapping.factory.default" /> | ||
<argument type="service" id="ivory.serializer.event.dispatcher" /> | ||
</service> | ||
|
||
<service id="ivory.serializer.navigator.event" class="Ivory\Serializer\Navigator\EventNavigator"> | ||
<argument type="service" id="ivory.serializer.navigator.default" /> | ||
<argument type="service" id="ivory.serializer.event.dispatcher" /> | ||
</service> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Event | ||
|
||
The bundle supports events and allows you to hook into the (de)-serialization process. If you want to learn more about | ||
the supported events, you can read this [documentation](https://github.com/egeloen/ivory-serializer/blob/master/doc/event.md). | ||
|
||
## Register a listener | ||
|
||
In order to register a listener on the event dispatcher, you need to use the `ivory.serializer.listener` tag as well | ||
as the `event` and `method` attributes: | ||
|
||
``` xml | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<container | ||
xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services | ||
http://symfony.com/schema/dic/services/services-1.0.xsd" | ||
> | ||
<services> | ||
<service | ||
id="acme.serializer.event.listener" | ||
class="Acme\Serializer\Event\CustomListener" | ||
> | ||
<tag | ||
name="ivory.serializer.listsner" | ||
event="serializer.pre_serialize" | ||
method="onPreSerialize" | ||
/> | ||
</service> | ||
</services> | ||
</container> | ||
``` | ||
|
||
## Register a subscriber | ||
|
||
To register a subscriber on the event dispatcher, you need to use the `ivory.serializer.subscriber` tag: | ||
|
||
``` xml | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<container | ||
xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services | ||
http://symfony.com/schema/dic/services/services-1.0.xsd" | ||
> | ||
<services> | ||
<service | ||
id="acme.serializer.event.listener" | ||
class="Acme\Serializer\Event\CustomSubscriber" | ||
> | ||
<tag name="ivory.serializer.subscriber" /> | ||
</service> | ||
</services> | ||
</container> | ||
``` | ||
|
||
## Disable Events | ||
|
||
If you don't use events, we recommend you to disable it since it adds some overhead: | ||
|
||
``` yaml | ||
ivory_serializer: | ||
event: | ||
enabled: false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ivory_serializer: | ||
event: | ||
enabled: false |
This file was deleted.
Oops, something went wrong.