diff --git a/lib/Drupal/Component/Plugin/Context/ContextDefinitionInterface.php b/lib/Drupal/Component/Plugin/Context/ContextDefinitionInterface.php index 16fdc8b..c7b69a0 100644 --- a/lib/Drupal/Component/Plugin/Context/ContextDefinitionInterface.php +++ b/lib/Drupal/Component/Plugin/Context/ContextDefinitionInterface.php @@ -150,7 +150,7 @@ public function addConstraint($constraint_name, $options = NULL); * Returns a validation constraint. * * @param string $constraint_name - * The name of the the constraint, i.e. its plugin id. + * The name of the constraint, i.e. its plugin id. * * @return array * A validation constraint definition which can be used for instantiating a diff --git a/lib/Drupal/Component/Plugin/Discovery/CachedDiscoveryInterface.php b/lib/Drupal/Component/Plugin/Discovery/CachedDiscoveryInterface.php index a9d95fc..5f9aa10 100644 --- a/lib/Drupal/Component/Plugin/Discovery/CachedDiscoveryInterface.php +++ b/lib/Drupal/Component/Plugin/Discovery/CachedDiscoveryInterface.php @@ -21,4 +21,17 @@ interface CachedDiscoveryInterface extends DiscoveryInterface { */ public function clearCachedDefinitions(); + /** + * Disable the use of caches. + * + * Can be used to ensure that uncached plugin definitions are returned, + * without invalidating all cached information. + * + * This will also remove all local/static caches. + * + * @param bool $use_caches + * FALSE to not use any caches. + */ + public function useCaches($use_caches = FALSE); + } diff --git a/lib/Drupal/Component/Plugin/Discovery/DiscoveryInterface.php b/lib/Drupal/Component/Plugin/Discovery/DiscoveryInterface.php index 5b44bf9..adaaa9c 100644 --- a/lib/Drupal/Component/Plugin/Discovery/DiscoveryInterface.php +++ b/lib/Drupal/Component/Plugin/Discovery/DiscoveryInterface.php @@ -37,7 +37,7 @@ public function getDefinition($plugin_id, $exception_on_invalid = TRUE); * * @return mixed[] * An array of plugin definitions (empty array if no definitions were - * found). + * found). Keys are plugin IDs. */ public function getDefinitions(); diff --git a/lib/Drupal/Component/Plugin/LazyPluginCollection.php b/lib/Drupal/Component/Plugin/LazyPluginCollection.php index 0564da0..f2a9ab0 100644 --- a/lib/Drupal/Component/Plugin/LazyPluginCollection.php +++ b/lib/Drupal/Component/Plugin/LazyPluginCollection.php @@ -12,7 +12,7 @@ * * @ingroup plugin_api */ -abstract class LazyPluginCollection implements \Iterator, \Countable { +abstract class LazyPluginCollection implements \IteratorAggregate, \Countable { /** * Stores all instantiated plugins. @@ -147,46 +147,12 @@ public function removeInstanceId($instance_id) { $this->remove($instance_id); } - /** - * {@inheritdoc} - */ - public function current() { - return $this->get($this->key()); - } - - /** - * {@inheritdoc} - */ - public function next() { - next($this->instanceIDs); - } - - /** - * {@inheritdoc} - */ - public function key() { - return key($this->instanceIDs); - } - - /** - * {@inheritdoc} - */ - public function valid() { - $key = key($this->instanceIDs); - // Check the key is valid but also that this key yields a plugin from get(). - // There can be situations where configuration contains data for a plugin - // that cannot be instantiated. In this case, this enables us to skip that - // plugin during iteration. - // @todo Look at removing when https://drupal.org/node/2080823 has been - // solved. - return $key !== NULL && $key !== FALSE && $this->get($key); - } - - /** - * {@inheritdoc} - */ - public function rewind() { - reset($this->instanceIDs); + public function getIterator() { + $instances = []; + foreach ($this->getInstanceIds() as $instance_id) { + $instances[$instance_id] = $this->get($instance_id); + } + return new \ArrayIterator($instances); } /** diff --git a/lib/Drupal/Component/Plugin/composer.json b/lib/Drupal/Component/Plugin/composer.json index 85caa41..09179e5 100644 --- a/lib/Drupal/Component/Plugin/composer.json +++ b/lib/Drupal/Component/Plugin/composer.json @@ -5,13 +5,13 @@ "homepage": "https://drupal.org/project/drupal", "license": "GPL-2.0+", "require": { - "php": ">=5.4.2" + "php": ">=5.4.2", }, "autoload": { "psr-0": { "Drupal\\Component\\Plugin\\": "" } - }, + } "suggest": { "symfony/validator": "Leveraged in the use of context aware plugins." }