vierbergenlars/manipulator-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

A set of classes to make modifying Symfony services and routes easier

0.1.0 2014-06-17 17:22 UTC

This package is not auto-updated.

Last update: 2020-10-26 07:41:12 UTC


README

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Latest Unstable Version License

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 Definition
  • removeService(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 configuration
  • removeImport(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