Commit e0f774b3 authored by webchick's avatar webchick

Issue #2189985 by tim.plunkett: Rename UnknownPluginException to PluginNotFoundException.

parent c08e301d
......@@ -7,7 +7,7 @@
namespace Drupal\Component\Plugin;
use Drupal\Component\Plugin\Exception\UnknownPluginException;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Utility\MapArray;
/**
......@@ -75,7 +75,7 @@ public function __construct(PluginManagerInterface $manager, array $configuratio
protected function initializePlugin($instance_id) {
$configuration = isset($this->configurations[$instance_id]) ? $this->configurations[$instance_id] : array();
if (!isset($configuration[$this->pluginKey])) {
throw new UnknownPluginException($instance_id);
throw new PluginNotFoundException($instance_id);
}
$this->set($instance_id, $this->manager->createInstance($configuration[$this->pluginKey], $configuration));
}
......
<?php
/**
* @file
* Contains \Drupal\Component\Plugin\Exception\PluginNotFoundException.
*/
namespace Drupal\Component\Plugin\Exception;
/**
* Plugin exception class to be thrown when a plugin ID could not be found.
*/
class PluginNotFoundException extends PluginException {
/**
* Construct an PluginNotFoundException exception.
*
* @param string $plugin_id
* The plugin ID that was not found.
*
* @see \Exception for remaining parameters.
*/
public function __construct($plugin_id, $message = '', $code = 0, \Exception $previous = NULL) {
if (empty($message)) {
$message = sprintf("Plugin ID '%s' was not found.", $plugin_id);
}
parent::__construct($message, $code, $previous);
}
}
<?php
/**
* @file
* Contains \Drupal\Component\Plugin\Exception\UnknownPluginException.
*/
namespace Drupal\Component\Plugin\Exception;
use Drupal\Component\Utility\String;
/**
* Plugin exception class to be thrown when a nonexistent plugin was requested.
*/
class UnknownPluginException extends PluginException {
/**
* Construct an UnknownPluginException exception.
*
* @param string $instance_id
* The invalid instance ID that failed.
*
* @see \Exception for remaining parameters.
*/
public function __construct($instance_id, $message = '', $code = 0, \Exception $previous = NULL) {
if (empty($message)) {
$message = String::format("Unknown plugin ID '@instance'.", array('@instance' => $instance_id));
}
parent::__construct($message, $code, $previous);
}
}
......@@ -8,7 +8,7 @@
namespace Drupal\Core\Entity;
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Component\Plugin\Exception\UnknownPluginException;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\String;
......@@ -170,7 +170,7 @@ public function getDefinition($entity_type_id, $exception_on_invalid = FALSE) {
return NULL;
}
throw new UnknownPluginException($entity_type_id, sprintf('The "%s" entity type does not exist.', $entity_type_id));
throw new PluginNotFoundException($entity_type_id, sprintf('The "%s" entity type does not exist.', $entity_type_id));
}
/**
......
......@@ -6,7 +6,7 @@
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Plugin\Exception\UnknownPluginException;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\field\Entity\Field;
use Drupal\field\Entity\FieldInstance;
use Drupal\file\Entity\File;
......@@ -76,7 +76,7 @@ function image_help($path, $arg) {
try {
$effect = entity_load('image_style', $arg[5])->getEffect($arg[7]);
}
catch (UnknownPluginException $e) {
catch (PluginNotFoundException $e) {
return NULL;
}
$effect_definition = $effect->getPluginDefinition();
......
......@@ -10,7 +10,7 @@
use Drupal\Core\Form\FormBase;
use Drupal\image\ConfigurableImageEffectInterface;
use Drupal\image\ImageStyleInterface;
use Drupal\Component\Plugin\Exception\UnknownPluginException;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Utility\String;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
......@@ -58,7 +58,7 @@ public function buildForm(array $form, array &$form_state, ImageStyleInterface $
try {
$this->imageEffect = $this->prepareImageEffect($image_effect);
}
catch (UnknownPluginException $e) {
catch (PluginNotFoundException $e) {
throw new NotFoundHttpException(String::format("Invalid effect id: '@id'.", array('@id' => $image_effect)));
}
$request = $this->getRequest();
......
......@@ -59,7 +59,8 @@ public function testGet() {
/**
* Tests the get method with an non existing plugin ID.
*
* @expectedException \Drupal\Component\Plugin\Exception\PluginException
* @expectedException \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @expectedExceptionMessage Plugin ID 'pear' was not found.
*/
public function testGetNotExistingPlugin() {
$this->setupPluginBag();
......
......@@ -223,7 +223,8 @@ public function providerTestGetDefinition() {
*
* @covers ::getDefinition()
*
* @expectedException \Drupal\Component\Plugin\Exception\UnknownPluginException
* @expectedException \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @expectedExceptionMessage The "pear" entity type does not exist.
*/
public function testGetDefinitionInvalidException() {
$this->setUpEntityManager();
......
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