Issue #1986802 by yched: Rename PluginInspectionInterface::getDefinition() to getPluginDefinition().

8.0.x
Alex Pott 2013-06-12 17:14:59 +01:00
parent 317357373e
commit 202fe604b4
22 changed files with 49 additions and 43 deletions

View File

@ -54,7 +54,7 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware
* Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::getContextDefinitions().
*/
public function getContextDefinitions() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
return !empty($definition['context']) ? $definition['context'] : array();
}
@ -62,7 +62,7 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware
* Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::getContextDefinition().
*/
public function getContextDefinition($name) {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
if (empty($definition['context'][$name])) {
throw new PluginException("The $name context is not a valid context.");
}

View File

@ -49,16 +49,16 @@ abstract class PluginBase implements PluginInspectionInterface {
}
/**
* Implements Drupal\Component\Plugin\PluginInterface::getPluginId().
* {@inheritdoc}
*/
public function getPluginId() {
return $this->pluginId;
}
/**
* Implements Drupal\Component\Plugin\PluginInterface::getDefinition().
* {@inheritdoc}
*/
public function getDefinition() {
public function getPluginDefinition() {
return $this->pluginDefinition;
}

View File

@ -29,5 +29,5 @@ interface PluginInspectionInterface {
* The plugin definition, as returned by the discovery object used by the
* plugin manager.
*/
public function getDefinition();
public function getPluginDefinition();
}

View File

@ -18,7 +18,7 @@ abstract class ConditionPluginBase extends ExecutablePluginBase implements Condi
* Implements \Drupal\Core\Form\FormInterface::getFormID().
*/
public function getFormID() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
return implode('_', array($definition['module'], $definition['id'], 'condition'));
}

View File

@ -41,7 +41,7 @@ abstract class ExecutablePluginBase extends ContextAwarePluginBase implements Ex
* options, keyed by option name.
*/
public function getConfigDefinitions() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
if (!empty($definition['configuration'])) {
return $definition['configuration'];
}
@ -58,7 +58,7 @@ abstract class ExecutablePluginBase extends ContextAwarePluginBase implements Ex
* if the option does not exist.
*/
public function getConfigDefinition($key) {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
if (!empty($definition['configuration'][$key])) {
return $definition['configuration'][$key];
}

View File

@ -33,7 +33,7 @@ class DefaultProcessor extends PluginBase implements ProcessorInterface {
public function settingsForm(array $form, array &$form_state) {
$config = config('aggregator.settings');
$processors = $config->get('processors');
$info = $this->getDefinition();
$info = $this->getPluginDefinition();
$items = drupal_map_assoc(array(3, 5, 10, 15, 20, 25), array($this, 'formatItems'));
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
$period[AGGREGATOR_CLEAR_NEVER] = t('Never');

View File

@ -32,7 +32,7 @@ class TestProcessor extends PluginBase implements ProcessorInterface {
public function settingsForm(array $form, array &$form_state) {
$config = config('aggregator.settings');
$processors = $config->get('processors');
$info = $this->getDefinition();
$info = $this->getPluginDefinition();
$form['processors'][$info['id']] = array(
'#type' => 'details',

View File

@ -111,7 +111,7 @@ abstract class BlockBase extends PluginBase implements BlockPluginInterface {
* @see \Drupal\block\BlockBase::blockForm()
*/
public function form($form, &$form_state) {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
$form['module'] = array(
'#type' => 'value',
'#value' => $definition['module'],

View File

@ -143,7 +143,7 @@ class BlockListController extends ConfigEntityListController implements FormInte
// Build blocks first for each region.
foreach ($entities as $entity_id => $entity) {
$definition = $entity->getPlugin()->getDefinition();
$definition = $entity->getPlugin()->getPluginDefinition();
$blocks[$entity->get('region')][$entity_id] = array(
'admin_label' => $definition['admin_label'],
'entity_id' => $entity_id,

View File

@ -45,7 +45,7 @@ class BlockPluginUI extends PluginUIBase {
public function form($form, &$form_state, $facet = NULL) {
// @todo Add an inline comment here.
list($plugin, $theme) = explode(':', $this->getPluginId());
$plugin_definition = $this->getDefinition();
$plugin_definition = $this->getPluginDefinition();
// @todo Find out how to let the manager be injected into the class.
$manager = drupal_container()->get($plugin_definition['manager']);
$plugins = $manager->getDefinitions();
@ -141,7 +141,7 @@ class BlockPluginUI extends PluginUIBase {
* Overrides \Drupal\system\Plugin\PluginUIBase::row().
*/
public function row($display_plugin_id, array $display_plugin_definition) {
$plugin_definition = $this->getDefinition();
$plugin_definition = $this->getPluginDefinition();
list($plugin, $theme) = explode(':', $this->getPluginId());
$row = array();
$row[] = check_plain($display_plugin_definition['admin_label']);
@ -180,7 +180,7 @@ class BlockPluginUI extends PluginUIBase {
* Returns a row array comaptible with theme_links().
*/
protected function facetLink($facet, $display_plugin_id, array $display_plugin_definition) {
$plugin_definition = $this->getDefinition();
$plugin_definition = $this->getPluginDefinition();
return array(
'title' => $display_plugin_definition[$facet],
'href' => $plugin_definition['path'] . '/' . $this->getPluginId() . '/' . $facet . ':' . $display_plugin_definition[$facet],
@ -222,7 +222,7 @@ class BlockPluginUI extends PluginUIBase {
* Returns a simple URL string for use within l().
*/
protected function allPluginsUrl($display_plugin_id, $display_plugin_definition) {
$plugin_definition = $this->getDefinition();
$plugin_definition = $this->getPluginDefinition();
return $plugin_definition['path'] . '/' . $this->getPluginId() . '/add';
}

View File

@ -65,7 +65,7 @@ abstract class PluginSettingsBase extends PluginBase implements PluginSettingsIn
* Implements Drupal\field\Plugin\PluginSettingsInterface::getDefaultSettings().
*/
public function getDefaultSettings() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
return $definition['settings'];
}

View File

@ -90,7 +90,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
// If the widget is handling multiple values (e.g Options), or if we are
// displaying an individual element, just get a single form element and make
// it the $delta value.
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
if (isset($get_delta) || $definition['multiple_values']) {
$delta = isset($get_delta) ? $get_delta : 0;
$element = array(
@ -357,7 +357,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
// Only set errors if the element is accessible.
if (!isset($element['#access']) || $element['#access']) {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
$is_multiple = $definition['multiple_values'];
foreach ($field_state['errors'] as $delta => $delta_errors) {

View File

@ -236,7 +236,7 @@ class DisplayOverview extends OverviewBase {
$table[$name]['format']['settings_edit_form'] = array();
if ($formatter) {
$formatter_type_info = $formatter->getDefinition();
$formatter_type_info = $formatter->getPluginDefinition();
// Generate the settings form and allow other modules to alter it.
$settings_form = $formatter->settingsForm($form, $form_state);

View File

@ -35,7 +35,7 @@ class StaticLayout extends PluginBase implements LayoutInterface {
* Implements Drupal\layout\Plugin\LayoutInterface::getRegions().
*/
public function getRegions() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
return $definition['regions'];
}
@ -43,7 +43,7 @@ class StaticLayout extends PluginBase implements LayoutInterface {
* Returns the list of CSS files associated with this layout.
*/
public function getStylesheetFiles() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
return isset($definition['stylesheets']) ? $definition['stylesheets'] : array();
}
@ -51,7 +51,7 @@ class StaticLayout extends PluginBase implements LayoutInterface {
* Returns the list of administrative CSS files associated with this layout.
*/
public function getAdminStylesheetFiles() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
// Fall back on regular CSS for the admin page if admin CSS not provided.
return isset($definition['admin stylesheets']) ? $definition['admin stylesheets'] : $this->getStylesheetFiles();
}
@ -60,7 +60,7 @@ class StaticLayout extends PluginBase implements LayoutInterface {
* Returns the list of JS files associated with this layout.
*/
public function getScriptFiles() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
return isset($definition['scripts']) ? $definition['scripts'] : array();
}
@ -68,7 +68,7 @@ class StaticLayout extends PluginBase implements LayoutInterface {
* Returns the list of administrative JS files associated with this layout.
*/
public function getAdminScriptFiles() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
return isset($definition['admin scripts']) ? $definition['admin scripts'] : $this->getScriptFiles();
}
@ -76,7 +76,7 @@ class StaticLayout extends PluginBase implements LayoutInterface {
* Implements Drupal\layout\Plugin\LayoutInterface::renderLayout().
*/
public function renderLayout($admin = FALSE, $regions = array()) {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
// Assemble a render array with the regions and attached CSS/JS.
$build = array(

View File

@ -25,7 +25,7 @@ abstract class ResourceBase extends PluginBase implements ResourceInterface {
*/
public function permissions() {
$permissions = array();
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
foreach ($this->availableMethods() as $method) {
$lowered_method = strtolower($method);
$permissions["restful $lowered_method $this->pluginId"] = array(

View File

@ -42,7 +42,7 @@ class EntityResource extends ResourceBase {
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function get($id) {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
$entity = entity_load($definition['entity_type'], $id);
if ($entity) {
if (!$entity->access('view')) {
@ -75,7 +75,7 @@ class EntityResource extends ResourceBase {
if (!$entity->access('create')) {
throw new AccessDeniedHttpException();
}
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
// Verify that the deserialized entity is of the type that we expect to
// prevent security issues.
if ($entity->entityType() != $definition['entity_type']) {
@ -121,7 +121,7 @@ class EntityResource extends ResourceBase {
if (empty($id)) {
throw new NotFoundHttpException();
}
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
if ($entity->entityType() != $definition['entity_type']) {
throw new BadRequestHttpException(t('Invalid entity type'));
}
@ -178,7 +178,7 @@ class EntityResource extends ResourceBase {
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function delete($id) {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
$entity = entity_load($definition['entity_type'], $id);
if ($entity) {
if (!$entity->access('delete')) {

View File

@ -53,7 +53,7 @@ class RequestHandler extends ContainerAware {
$config = $this->container->get('config.factory')->get('rest.settings')->get('resources');
$enabled_formats = $config[$plugin][$request->getMethod()];
if (empty($enabled_formats) || isset($enabled_formats[$format])) {
$definition = $resource->getDefinition();
$definition = $resource->getPluginDefinition();
$class = $definition['serialization_class'];
try {
$unserialized = $serializer->deserialize($received, $class, $format);

View File

@ -77,7 +77,7 @@ class ImageToolkitForm extends SystemConfigFormBase {
// If we have available toolkits, allow the user to select the image toolkit
// to use and load the settings forms.
foreach ($this->availableToolkits as $id => $toolkit) {
$definition = $toolkit->getDefinition();
$definition = $toolkit->getPluginDefinition();
$form['image_toolkit']['#options'][$id] = $definition['title'];
$form['image_toolkit_settings'][$id] = array(
'#type' => 'fieldset',

View File

@ -111,7 +111,7 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface {
* {@inheritdoc}
*/
public function getPluginDefinition() {
return $this->getPlugin()->getDefinition();
return $this->getPlugin()->getPluginDefinition();
}
/**

View File

@ -21,7 +21,7 @@ abstract class PluginUIBase extends PluginBase implements PluginUIInterface {
* Implements \Drupal\system\Plugin\PluginUIInterface::form().
*/
public function form($form, &$form_state) {
$plugin_definition = $this->getDefinition();
$plugin_definition = $this->getPluginDefinition();
// @todo Find out how to let the manager be injected into the class.
if (class_exists($plugin_definition['manager'])) {
$manager = new $plugin_definition['manager']();
@ -63,7 +63,7 @@ abstract class PluginUIBase extends PluginBase implements PluginUIInterface {
* Returns TRUE if plugins of this type can be accessed.
*/
public function access() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
return call_user_func_array($definition['access_callback'], $definition['access_arguments']);
}
@ -79,7 +79,7 @@ abstract class PluginUIBase extends PluginBase implements PluginUIInterface {
* An array that represents a table row in the final user interface output.
*/
public function row($display_plugin_id, array $display_plugin_definition) {
$plugin_definition = $this->getDefinition();
$plugin_definition = $this->getPluginDefinition();
return array($display_plugin_definition['title'], l($plugin_definition['link_title'], $plugin_definition['config_path'] . '/' . $display_plugin_id));
}

View File

@ -21,26 +21,32 @@ class InspectionTest extends PluginTestBase {
}
/**
* Ensure the test plugins correctly implement getPluginId() and getDefinition().
* Ensure the test plugins correctly implement getPluginId() and getPluginDefinition().
*/
function testInspection() {
foreach (array('user_login') as $id) {
$plugin = $this->testPluginManager->createInstance($id);
$expected_definition = $this->testPluginExpectedDefinitions[$id];
$this->assertIdentical($plugin->getPluginId(), $id);
$this->assertIdentical($this->testPluginManager->getDefinition($id), $this->testPluginExpectedDefinitions[$id]);
$this->assertIdentical($this->testPluginManager->getDefinition($id), $expected_definition);
$this->assertIdentical($plugin->getPluginDefinition(), $expected_definition);
}
// Skip the 'menu' derived blocks, because MockMenuBlock does not implement
// PluginInspectionInterface. The others do by extending PluginBase.
foreach (array('user_login', 'layout') as $id) {
$plugin = $this->mockBlockManager->createInstance($id);
$expected_definition = $this->mockBlockExpectedDefinitions[$id];
$this->assertIdentical($plugin->getPluginId(), $id);
$this->assertIdentical($this->mockBlockManager->getDefinition($id), $this->mockBlockExpectedDefinitions[$id]);
$this->assertIdentical($this->mockBlockManager->getDefinition($id), $expected_definition);
$this->assertIdentical($plugin->getPluginDefinition(), $expected_definition);
}
// Test a plugin manager that provides defaults.
foreach (array('test_block1', 'test_block2') as $id) {
$plugin = $this->defaultsTestPluginManager->createInstance($id);
$expected_definition = $this->defaultsTestPluginExpectedDefinitions[$id];
$this->assertIdentical($plugin->getPluginId(), $id);
$this->assertIdentical($this->defaultsTestPluginManager->getDefinition($id), $this->defaultsTestPluginExpectedDefinitions[$id]);
$this->assertIdentical($this->defaultsTestPluginManager->getDefinition($id), $expected_definition);
$this->assertIdentical($plugin->getPluginDefinition(), $expected_definition);
}
}

View File

@ -178,7 +178,7 @@ class ViewAddFormController extends ViewFormControllerBase implements EntityCont
public function validate(array $form, array &$form_state) {
$wizard_type = $form_state['values']['show']['wizard_key'];
$wizard_instance = $this->wizardManager->createInstance($wizard_type);
$form_state['wizard'] = $wizard_instance->getDefinition();
$form_state['wizard'] = $wizard_instance->getPluginDefinition();
$form_state['wizard_instance'] = $wizard_instance;
$errors = $form_state['wizard_instance']->validateView($form, $form_state);