code ★★☆ (provided by symfony/event-dispatcher component) Steps to introduce 1. Create event class 2. Dispatch event 3. Process result (if applicable) Comments Can be used inside of the core logic and works with multiple clients by default
the controller has been resolved but before executing it • Used to initialize things or change the controller just before the controller is executed Example usage Collecting profiler data about routing (see Symfony\Component\HttpKernel\DataCollector\RequestDataCollector) Source symfony/http-kernel package
event is dispatched and how to change its outcome (if applicable) • Group related events by introducing base class or marker interface. For example. For example: 1. Symfony\Component\Form\FormEvent 2. Symfony\Component\HttpKernel\Event\KernelEvent 3. Symfony\Component\Workflow\Event\Event
objects Infrastructure code ★☆☆ (provided by symfony/dependency-injection component) Steps to introduce 1. Extract an interface 2. Register the service using interface FQCN introduced in a previous point as an alias to concreate implementation. 3. Provide abstract decorator (optional) Comments N/A
that implements a decorated interface and delegates execution to the decorated instance. • Eliminates boilerplate code in client implementations when decorating complex interfaces. • Must-have for complex interfaces
EntityManager: Inheritance is not a valid extension point for the EntityManager. Instead you should take look at the \Doctrine\ORM\Decorator\EntityManagerDecorator and wrap your entity manager in a decorator. Source: https://github.com/doctrine/orm/blob/3.3.x/src/EntityManager.php#L53-L56
are indented to be decorated. Expose them as a contract. • Create abstract decorator in case of the complex interfaces • Avoid decoration for a combination of main interfaces and optional feature interfaces
code ★★☆ (provided by symfony/dependency-injection component) Steps to introduce 1. Introduce strategy interface 2. Implement out-of-the-box implementations (optional) 3. Register service with tag of your choice 4. Use the right strategy Comments N/A
strategy based on configuration • Adding & removing strategies in runtime Infrastructure code ★★★ (custom code) Steps to introduce 1. Introduce registry class along side with corresponding interface Comments N/A
abstractions. Testing Complexity You need to account for various customization scenarios during testing. Maintenance Effort Once an extension point is established, removing or modifying it can break existing customizations. Extension point requires extensive documentation. … but they come with a cost:
customization without altering the original codebase • Design patterns are foundation of extensibility. Both symfony/event- dispatcher & symfony/dependency-injection components provides necessary infrastructure code for extension points in most cases • Extension points are easy to introduce, but they come with a cost of increased code & testing complexity as well as extra maintenance effort