2017 © Pedro Peláez
 

drupal-module service_container

Service Container based on CTools plugins with Symfony Integration

image

lionsad/service_container

Service Container based on CTools plugins with Symfony Integration

  • Tuesday, August 2, 2016
  • by LionsAd
  • Repository
  • 4 Watchers
  • 5 Stars
  • 983 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 5 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

service_container

Build Status Coverage Status Scrutinizer Code Quality ![Gitter](https://badges.gitter.im/Join Chat.svg), (*1)

Versions

Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Service Container is an API module based on ctools to enable a Drupal 7 quick and easy lightweight service container with 100% unit test coverage., (*3)

It is very similar in syntax to a Symfony container, but was written from scratch as a symfony dependency was not wanted - using some of Drupal 8 Core and Component directly. They will likely depend on a drupal8core project in the future - but for now the copy is fine., (*4)

This allows to use an extensible service container (like in Drupal 8) and write modules in Drupal 7 as if they were using Drupal 8., (*5)

The main benefit is being able to use unit testing but also to write Drupal 7 module with Drupal 8 style of coding in mind., (*6)

The module uses PHP Unit and travis.yml, but the tests and a composer.json are isolated in the tests/ directory, so no vendor or composer multi map is needed by default., (*7)

It was originally written for the render_cache module, but since then others have expressed interest in using it, so it was split it out and made a dependency of render_cache instead., (*8)

You need:, (*9)

or any other PSR-4 autoloader., (*10)

Registering CTools plugins

By default the service_container supports CTools discovery, to register your plugins all you need to do is:, (*11)

    $parameters['ctools_plugins_auto_discovery']['render_cache'] = TRUE

And you can then get a plugin via:, (*12)

    $rcc = \Drupal::service('render_cache.controller')->createInstance('block');

Because the plugin managers implement the whole discovery interface, you can get all definitions with ease., (*13)

  $plugins = \Drupal::service('render_cache.controller')->getDefinitions();

Your plugin itself looks like:, (*14)

cat modules/render_cache_block/src/RenderCache/Controller/block.inc, (*15)

$plugin = array(
  'class' => "\\Drupal\\render_cache_block\\RenderCache\\Controller\\BlockController",
  'arguments' => array('@render_stack', '@render_cache.cache'),
);

So you can use normal container parameter syntax., (*16)

Provides the following services:

  • module handler ('module_handler') and module installer ('module_installer')
  • service container ('service_container')
  • database ('database')
  • key value store ('keyvalue', 'keyvalue.database')
  • variable, a wrapper for variable_get() / variable_set()
  • A lock ('lock')
  • A wrapper for url() / l() ('url_generator', 'link_generator')
  • Flood, a wrapper for the flood mechanisms
  • Messenger, a wrapper for displaying messages
  • Drupal 7 Legacy, a wrapper for accessing the Drupal 7 legacy functions.
  • More to come...

Testing

  • service_container is tested via PHPUnit for code correctness. (run ./tests/run-tests.sh)
  • service_container is tested via simpletest for integration with Drupal. (run ./tests/run-simpletests.sh)
  • service_container is tested via PHPUnit for code coverage. (run ./tests/run-coverage.sh)

List of Drupal 8 core services that we've altered

See the file HACK.md for more details., (*17)

Examples of modules that use this module

The Versions

02/08 2016

dev-7.x-1.x

dev-7.x-1.x https://www.drupal.org/project/service_container

Service Container based on CTools plugins with Symfony Integration

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

by Fabian Franz

14/12 2015

dev-use-d8-container

dev-use-d8-container https://www.drupal.org/project/service_container

Service Container based on CTools plugins with Symfony Integration

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

by Fabian Franz

16/07 2015

dev-pr--82

dev-pr--82 https://www.drupal.org/project/service_container

Service Container based on CTools plugins with Symfony Integration

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

by Fabian Franz

16/07 2015

1.0.0-beta5

1.0.0.0-beta5 https://www.drupal.org/project/service_container

Service Container based on CTools plugins with Symfony Integration

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

by Fabian Franz

25/06 2015

1.0.0-beta4

1.0.0.0-beta4 https://www.drupal.org/project/service_container

Service Container based on CTools plugins with Symfony Integration

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

by Fabian Franz

23/06 2015

1.0.0-beta3

1.0.0.0-beta3 https://www.drupal.org/project/service_container

Service Container based on CTools plugins with Symfony Integration

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

by Fabian Franz

14/06 2015

dev-8.x-1.x

dev-8.x-1.x https://www.drupal.org/project/service_container

Service Container based on CTools plugins with Symfony Integration

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

by Fabian Franz

10/06 2015

1.0.0-beta2

1.0.0.0-beta2 https://www.drupal.org/project/service_container

Service Container based on CTools plugins with Symfony Integration

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

by Fabian Franz

10/06 2015

1.0.0-beta1

1.0.0.0-beta1 https://www.drupal.org/project/service_container

Service Container based on CTools plugins with Symfony Integration

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

by Fabian Franz