Install

Works with Drupal: 7.x

Using Composer to manage Drupal site dependencies

Downloads

Download tar.gz 466.29 KB
MD5: dd91b1270661c99e8529b7a687e57ff6
SHA-1: 94399002fc0cbe10b1362d0e52fd8b6506236ee2
SHA-256: 1f41171cdb14538919fab1d71eee3c669da57341975bddb6ccc1054918236aca
Download zip 950.2 KB
MD5: 64a6831408b1717f289a262c780b1997
SHA-1: cc98a31c5fe225e5e01e8df7eecfcf7529540a89
SHA-256: 9a86342f6f90a8f9ae143f0766cac95d66fe268d5410722c8d163d1d64fead34

Release notes

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 servicecontainerannotation_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:
    /**
     * @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:

    php
      /**
       * 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:

    Created by: pol
    Created on: 23 Jun 2015 at 09:23 UTC
    Last updated: 25 Jun 2015 at 18:03 UTC
    Bug fixes
    New features
    Unsupported

    Other releases