A set of classes to make modifying Symfony services and routes easier.
composer require vierbergenlars/manipulator-bundle
All manipulators require the path to be passed in their constructor. The file must already exist and have a valid structure.
The write()
method writes all changes to the original file.
Use XmlServiceManipulator
or YamlServiceManipulator
, depending on the type of the configuration file.
addService(string $id, Definition $service)
: adds a service to the configuration. Pass the service id, and the Symfony DI DefinitionremoveService(string $id)
: remove a service from the configuration.
Use XmlRouteManipulator
or YamlRouteManipulator
, depending on the type of the configuration file.
addRoute(string $name, array $options)
: Adds a route to the configuration.removeRoute(string $name)
: Removes a route from the configuration.addImport(string $resource, array $options)
: Adds an import of a resource to the configurationremoveImport(string $resource)
: Removes an import from the configuration.
An array of configuration options for the route or import.
The options correspond to the settings structure in a routing YAML file, but they are listed below for reference.
Have a look at the symfony documentation
Key | Type | Description |
---|---|---|
path | string | Path that the route will match (route only) |
type | string | Type of the import (import only) |
prefix | string | Path to prepend to imported routes (import only) |
host | string | Host to match for the route(s) |
schemes | string | HTTP schemes the route(s) will respond to |
methods | string | HTTP methods the route(s) will respond to |
defaults | array | Map of default settings for variables in the route |
requirements | array | Map of requirements for variables in the route |
options | array | Map of internal options for the route (rarely used) |
condition | string | Custom condition that determines if the route matches |