vierbergenlars / manipulator-bundle
A set of classes to make modifying Symfony services and routes easier
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/vierbergenlars/manipulator-bundle
Requires
- symfony/dependency-injection: ~2.1
- symfony/yaml: ~2.1
- vierbergenlars/xml: ~0.3.0
Requires (Dev)
- mikey179/vfsstream: ~1.2
This package is not auto-updated.
Last update: 2020-10-26 07:41:12 UTC
README
A set of classes to make modifying Symfony services and routes easier.
Installation
composer require vierbergenlars/manipulator-bundle
Usage
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.
Modify services
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.
Modify routing
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.
$options
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 |