Commit 19e6c2c0 authored by alexpott's avatar alexpott
Browse files

Issue #1987298 by tim.plunkett, quicksketch: Shorten directory structure and...

Issue #1987298 by tim.plunkett, quicksketch: Shorten directory structure and PSR-0 namespacing for plugins.
parent a57952c6
......@@ -25,7 +25,7 @@ class ArchiverManager extends PluginManagerBase {
* keyed by the corresponding namespace to look for plugin implementations,
*/
public function __construct(\Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('Core', 'Archiver', $namespaces);
$this->discovery = new AnnotatedClassDiscovery('Archiver', $namespaces);
$this->discovery = new AlterDecorator($this->discovery, 'archiver_info');
$this->discovery = new CacheDecorator($this->discovery, 'archiver_info');
}
......
......@@ -29,7 +29,7 @@ class ConditionManager extends PluginManagerBase implements ExecutableManagerInt
* keyed by the corresponding namespace to look for plugin implementations,
*/
public function __construct(\Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('Core', 'Condition', $namespaces);
$this->discovery = new AnnotatedClassDiscovery('Condition', $namespaces);
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new AlterDecorator($this->discovery, 'condition_info');
$this->discovery = new CacheDecorator($this->discovery, 'condition:' . language(LANGUAGE_TYPE_INTERFACE)->langcode);
......
......@@ -50,7 +50,7 @@ public function __construct(\Traversable $namespaces) {
$annotation_namespaces = array(
'Drupal\Core\Entity\Annotation' => DRUPAL_ROOT . '/core/lib',
);
$this->discovery = new AnnotatedClassDiscovery('Core', 'Entity', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\EntityType');
$this->discovery = new AnnotatedClassDiscovery('Core/Entity', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\EntityType');
$this->discovery = new InfoHookDecorator($this->discovery, 'entity_info');
$this->discovery = new AlterDecorator($this->discovery, 'entity_info');
$this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'cache', CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE));
......
......@@ -38,14 +38,12 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery {
/**
* Constructs an AnnotatedClassDiscovery object.
*
* @param string $owner
* The module name that defines the plugin type.
* @param string $type
* The plugin type, for example filter.
* @param string $subdir
* The plugin's subdirectory, for example views/filter.
* @param \Traversable $root_namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations,
* \Plugin\$owner\$type will be appended to each namespace.
* \Plugin\$subdir will be appended to each namespace.
* @param array $annotation_namespaces
* (optional) The namespaces of classes that can be used as annotations.
* Defaults to an empty array.
......@@ -53,9 +51,8 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery {
* (optional) The name of the annotation that contains the plugin definition.
* Defaults to 'Drupal\Component\Annotation\Plugin'.
*/
function __construct($owner, $type, \Traversable $root_namespaces, $annotation_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin') {
$this->owner = $owner;
$this->type = $type;
function __construct($subdir, \Traversable $root_namespaces, $annotation_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin') {
$this->subdir = str_replace('/', '\\', $subdir);
$this->rootNamespacesIterator = $root_namespaces;
$annotation_namespaces += array(
'Drupal\Component\Annotation' => DRUPAL_ROOT . '/core/lib',
......@@ -71,7 +68,7 @@ function __construct($owner, $type, \Traversable $root_namespaces, $annotation_n
protected function getPluginNamespaces() {
$plugin_namespaces = array();
foreach ($this->rootNamespacesIterator as $namespace => $dir) {
$plugin_namespaces["$namespace\\Plugin\\{$this->owner}\\{$this->type}"] = array($dir);
$plugin_namespaces["$namespace\\Plugin\\{$this->subdir}"] = array($dir);
}
return $plugin_namespaces;
......
......@@ -44,7 +44,7 @@ class ConstraintManager extends PluginManagerBase {
* keyed by the corresponding namespace to look for plugin implementations,
*/
public function __construct(\Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('Validation', 'Constraint', $namespaces);
$this->discovery = new AnnotatedClassDiscovery('Validation/Constraint', $namespaces);
$this->discovery = new StaticDiscoveryDecorator($this->discovery, array($this, 'registerDefinitions'));
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition'));
......
......@@ -27,7 +27,7 @@ class AggregatorPluginManager extends PluginManagerBase {
* keyed by the corresponding namespace to look for plugin implementations,
*/
public function __construct($type, \Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('aggregator', $type, $namespaces);
$this->discovery = new AnnotatedClassDiscovery("aggregator/$type", $namespaces);
$this->discovery = new CacheDecorator($this->discovery, "aggregator_$type:" . language(LANGUAGE_TYPE_INTERFACE)->langcode);
$this->factory = new DefaultFactory($this->discovery);
}
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\aggregator\Plugin\block\block\AggregatorCategoryBlock.
* Contains \Drupal\aggregator\Plugin\Block\AggregatorCategoryBlock.
*/
namespace Drupal\aggregator\Plugin\block\block;
namespace Drupal\aggregator\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\aggregator\Plugin\block\block\AggregatorFeedBlock.
* Contains \Drupal\aggregator\Plugin\Block\AggregatorFeedBlock.
*/
namespace Drupal\aggregator\Plugin\block\block;
namespace Drupal\aggregator\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
......
......@@ -7,7 +7,6 @@
use Drupal\custom_block\Plugin\Core\Entity\CustomBlockType;
use Drupal\custom_block\Plugin\Core\Entity\CustomBlock;
use Drupal\custom_block\Plugin\block\block\CustomBlockBlock;
use Drupal\block\Plugin\Core\Entity\Block;
/**
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\custom_block\Plugin\block\block\CustomBlockBlock.
* Contains \Drupal\custom_block\Plugin\Block\CustomBlockBlock.
*/
namespace Drupal\custom_block\Plugin\block\block;
namespace Drupal\custom_block\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
......
<?php
/**
* Contains \Drupal\block\Plugin\system\plugin_ui\BlockPluginUI.
* Contains \Drupal\block\Plugin\PluginUI\BlockPluginUI.
*/
namespace Drupal\block\Plugin\system\plugin_ui;
namespace Drupal\block\Plugin\PluginUI;
use Drupal\system\Plugin\PluginUIBase;
use Drupal\Component\Annotation\Plugin;
......
......@@ -32,7 +32,7 @@ class BlockManager extends PluginManagerBase {
* keyed by the corresponding namespace to look for plugin implementations,
*/
public function __construct(\Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('block', 'block', $namespaces);
$this->discovery = new AnnotatedClassDiscovery('Block', $namespaces);
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new AlterDecorator($this->discovery, 'block');
$this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'block', CacheBackendInterface::CACHE_PERMANENT, array('block'));
......
......@@ -8,7 +8,7 @@
namespace Drupal\block\Tests;
use Drupal\simpletest\DrupalUnitTestBase;
use Drupal\block_test\Plugin\block\block\TestHtmlIdBlock;
use Drupal\block_test\Plugin\Block\TestHtmlIdBlock;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\block\BlockStorageController;
use Drupal\Core\Entity\EntityMalformedException;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\block_test\Plugin\block\block\TestCacheBlock.
* Contains \Drupal\block_test\Plugin\Block\TestCacheBlock.
*/
namespace Drupal\block_test\Plugin\block\block;
namespace Drupal\block_test\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\block_test\Plugin\block\block\TestHtmlIdBlock.
* Contains \Drupal\block_test\Plugin\Block\TestHtmlIdBlock.
*/
namespace Drupal\block_test\Plugin\block\block;
namespace Drupal\block_test\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\block_test\Plugin\block\block\TestXSSTitleBlock.
* Contains \Drupal\block_test\Plugin\Block\TestXSSTitleBlock.
*/
namespace Drupal\block_test\Plugin\block\block;
namespace Drupal\block_test\Plugin\Block;
use Drupal\Component\Annotation\Plugin;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\book\Plugin\block\block\BookNavigationBlock.
* Contains \Drupal\book\Plugin\Block\BookNavigationBlock.
*/
namespace Drupal\book\Plugin\block\block;
namespace Drupal\book\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
......
......@@ -29,7 +29,7 @@ class CKEditorPluginManager extends PluginManagerBase {
* keyed by the corresponding namespace to look for plugin implementations,
*/
public function __construct(\Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('ckeditor', 'plugin', $namespaces);
$this->discovery = new AnnotatedClassDiscovery('CKEditorPlugin', $namespaces);
$this->discovery = new AlterDecorator($this->discovery, 'ckeditor_plugin_info');
$this->discovery = new CacheDecorator($this->discovery, 'ckeditor_plugin');
$this->factory = new DefaultFactory($this->discovery);
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\ckeditor\Plugin\ckeditor\plugin\Internal.
* Contains \Drupal\ckeditor\Plugin\CKEditorPlugin\Internal.
*/
namespace Drupal\ckeditor\Plugin\ckeditor\plugin;
namespace Drupal\ckeditor\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\Component\Utility\NestedArray;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\ckeditor\Plugin\ckeditor\plugin\StylesCombo.
* Contains \Drupal\ckeditor\Plugin\CKEditorPlugin\StylesCombo.
*/
namespace Drupal\ckeditor\Plugin\ckeditor\plugin;
namespace Drupal\ckeditor\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\ckeditor\CKEditorPluginConfigurableInterface;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment