Skip to content

Releases: LionsAd/service_container

7.x-1.0-beta5

03 Aug 13:24
Compare
Choose a tag to compare

Features

  • Allows Annotation plugins to specify the 'plugin_manager_name' explicitly.

Bug fixed

  • Issue #2522032 by das-peter: AnnotatedClassDiscovery::getDefinitions() creates invalid class names
  • Issue #2527162: Cannot call global functions that take a method by reference
  • Fix syntax of .services.yml of module service_container_block.

1.0.0-beta5

03 Aug 13:24
Compare
Choose a tag to compare

Features

  • Allows Annotation plugins to specify the 'plugin_manager_name' explicitly.

Bug fixed

  • Issue #2522032 by das-peter: AnnotatedClassDiscovery::getDefinitions() creates invalid class names
  • Issue #2527162: Cannot call global functions that take a method by reference
  • Fix syntax of .services.yml of module service_container_block.

7.x-1.0-beta4

25 Jun 18:02
Compare
Choose a tag to compare

Mostly a bugfix release but some important stuff has changed since beta3.

The way CTools and Annotated plugins are declared has been changed.

Using PHP before:

  /**
   * {@inheritdoc}
   */
  public function getContainerDefinition() {
    $services = array();
    $parameters['ctools_plugins_auto_discovery']['service_container_test_ctools'] = TRUE;

    return array(
      'parameters' => $parameters,
      'services' => $services,
    );
  }

Using PHP now:

  /**
   * {@inheritdoc}
   */
  public function getContainerDefinition() {
    $services = array();
    $parameters['ctools_plugins_auto_discovery.service_container_test_ctools'] = array('service_container_test_ctools');

    return array(
      'parameters' => $parameters,
      'services' => $services,
    );
  }

Using Yaml before:

parameters:
  annotated_plugins_auto_discovery:
    - { owner: 'sc_doctrine_test', type: 'Plugin1', directory: 'Plugin/Plugin1', class: 'Drupal\Component\Annotation\Plugin' }
    - { owner: 'sc_doctrine_test', type: 'Plugin2', directory: 'Plugin/Plugin2', class: 'Drupal\Component\Annotation\Plugin' }

Using Yaml now:

parameters:
  annotated_plugins_auto_discovery.service_container_annotation_discovery_test:
    - { owner: 'sc_doctrine_test', type: 'Plugin1', directory: 'Plugin/Plugin1', class: 'Drupal\Component\Annotation\Plugin' }
    - { owner: 'sc_doctrine_test', type: 'Plugin2', directory: 'Plugin/Plugin2', class: 'Drupal\Component\Annotation\Plugin' }

1.0.0-beta4

25 Jun 18:04
Compare
Choose a tag to compare

Mostly a bugfix release but some important stuff has changed since beta3.

The way CTools and Annotated plugins are declared has been changed.

Using PHP before:

  /**
   * {@inheritdoc}
   */
  public function getContainerDefinition() {
    $services = array();
    $parameters['ctools_plugins_auto_discovery']['service_container_test_ctools'] = TRUE;

    return array(
      'parameters' => $parameters,
      'services' => $services,
    );
  }

Using PHP now:

  /**
   * {@inheritdoc}
   */
  public function getContainerDefinition() {
    $services = array();
    $parameters['ctools_plugins_auto_discovery.service_container_test_ctools'] = array('service_container_test_ctools');

    return array(
      'parameters' => $parameters,
      'services' => $services,
    );
  }

Using Yaml before:

parameters:
  annotated_plugins_auto_discovery:
    - { owner: 'sc_doctrine_test', type: 'Plugin1', directory: 'Plugin/Plugin1', class: 'Drupal\Component\Annotation\Plugin' }
    - { owner: 'sc_doctrine_test', type: 'Plugin2', directory: 'Plugin/Plugin2', class: 'Drupal\Component\Annotation\Plugin' }

Using Yaml now:

parameters:
  annotated_plugins_auto_discovery.service_container_annotation_discovery_test:
    - { owner: 'sc_doctrine_test', type: 'Plugin1', directory: 'Plugin/Plugin1', class: 'Drupal\Component\Annotation\Plugin' }
    - { owner: 'sc_doctrine_test', type: 'Plugin2', directory: 'Plugin/Plugin2', class: 'Drupal\Component\Annotation\Plugin' }

7.x-1.0-beta3

23 Jun 09:26
Compare
Choose a tag to compare

Security:

  • Issue #2508654 fixed, see details on drupal.org: Service Container was not affected directly, only custom modules depending on that file (Drupal/Component/Transliteration/PhpTransliteration.php) could have been vulnerable.

New features:

  • Submodule: service_container_annotation_discovery to declare plugins using annotations.
  • Plugins can now be constructed the same way as in Drupal 8.

New features documentation:

service_container_annotation_discovery:

This discovery module will use the doctrine annotation system to discover plugins.
How to get your plugin discovered automatically ?

  • Add a dependency to service_container_annotation_discovery in the info file of your module.
  • Create a file: yourmodule.services.yml:
parameters:
  annotated_plugins_auto_discovery:
    - { owner: 'plugin.manager', type: 'block', directory: 'Plugin/Block', class: 'Drupal\Core\Block\Annotation\Block' }

Parameters details:
owner: The owner of the plugins, usually your module name. In Drupal 8 the convention is to use simply 'plugin.manager', but then your type should be unique, e.g. commerce_plugin.
type: The type of plugin
directory: Where to find your plugin files, relative to [each-module-name]/src. No trailing slashes.
class: The class used for your annotations. (optional)

  • Create a plugin, create a file: [your_module]/src/Plugin/Block/YourChosenNameBlock.php:
<?php
/**
 * @file
 * Contains \Drupal\your_module\Plugin\Block\YourChosenNameBlock.
 */
namespace Drupal\your_module\Plugin\Block;
use Drupal\Component\Annotation\Plugin;
/**
 * Defines a Drupal Block.
 *
 * @Block(
 *   id = "YourChosenNameBlock",
 *   admin_label = "Your Module admin label",
 *   label = "Your Module chosen label Block",
 *   category = "Utility"
 * )
 */
class YourChosenNameBlock {
  /**
   * {@inheritdoc}
   */
  public function build() {
    return 'Hello World !';
  }
}
?>
  • Empty the cache
  • Use your plugin everywhere using:
\Drupal::service('plugin.manager.block')->createInstance('YourChosenNameBlock');

( This last part is subject to change still as we want to enable modules to use static constructors as well. )

  • Profit.

Drupal 8 style plugins

Plugins are now extending the Drupal 8 plugin base class: lib/Drupal/Component/Plugin/PluginBase.php
It means that the constructor of these plugins must be updated to match the requierements:

  /**
   * Constructs a Drupal\Component\Plugin\PluginBase object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition) {}

Bug fixes:

  • Errors related to alias handling and PhpArrayDumper are gone.
  • Drupal 8 component update
  • Add StringTranslationWrapper
  • Documentation update
  • Add some missing tests
  • Add methods documentation in Drupal 7 Legacy service
  • README.md and HACK.md update
  • Submodules files structure reorganization.

Closed pull requests: