Commit 202fe604 authored by alexpott's avatar alexpott

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

Issue #1986802 by yched: Rename PluginInspectionInterface::getDefinition() to getPluginDefinition().
parent 31735737
......@@ -54,7 +54,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi
* 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 @@ public function getContextDefinitions() {
* 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.");
}
......
......@@ -49,16 +49,16 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi
}
/**
* 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;
}
......
......@@ -29,5 +29,5 @@ public function getPluginId();
* The plugin definition, as returned by the discovery object used by the
* plugin manager.
*/
public function getDefinition();
public function getPluginDefinition();
}
......@@ -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'));
}
......
......@@ -41,7 +41,7 @@ public function setExecutableManager(ExecutableManagerInterface $executableManag
* 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 @@ public function getConfigDefinitions() {
* 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];
}
......
......@@ -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');
......
......@@ -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',
......
......@@ -111,7 +111,7 @@ public function access() {
* @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'],
......
......@@ -143,7 +143,7 @@ public function buildForm(array $form, array &$form_state) {
// 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,
......
......@@ -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 @@ public function tableHeader() {
* 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 @@ public function row($display_plugin_id, array $display_plugin_definition) {
* 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 @@ protected function facetCompare($facet, $display_plugin_definition) {
* 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';
}
......
......@@ -65,7 +65,7 @@ protected function mergeDefaults() {
* Implements Drupal\field\Plugin\PluginSettingsInterface::getDefaultSettings().
*/
public function getDefaultSettings() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
return $definition['settings'];
}
......
......@@ -90,7 +90,7 @@ public function form(EntityInterface $entity, $langcode, array $items, array &$f
// 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 @@ public function flagErrors(EntityInterface $entity, $langcode, array $items, arr
// 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) {
......
......@@ -236,7 +236,7 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL,
$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);
......
......@@ -35,7 +35,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi
* Implements Drupal\layout\Plugin\LayoutInterface::getRegions().
*/
public function getRegions() {
$definition = $this->getDefinition();
$definition = $this->getPluginDefinition();
return $definition['regions'];
}
......@@ -43,7 +43,7 @@ public function getRegions() {
* 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 @@ public function getStylesheetFiles() {
* 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 @@ public function getAdminStylesheetFiles() {
* 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 @@ public function getScriptFiles() {
* 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 @@ public function getAdminScriptFiles() {
* 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(
......
......@@ -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(
......
......@@ -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 @@ public function post($id, EntityInterface $entity) {
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 @@ public function patch($id, EntityInterface $entity) {
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 @@ public function patch($id, EntityInterface $entity) {
* @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')) {
......
......@@ -53,7 +53,7 @@ public function handle(Request $request, $id = NULL) {
$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);
......
......@@ -77,7 +77,7 @@ public function buildForm(array $form, array &$form_state) {
// 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',
......
......@@ -111,7 +111,7 @@ public function setPlugin($plugin_id) {
* {@inheritdoc}
*/
public function getPluginDefinition() {
return $this->getPlugin()->getDefinition();
return $this->getPlugin()->getPluginDefinition();
}
/**
......
......@@ -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 @@ public function formSubmit($form, &$form_state) {
* 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 @@ public function access() {
* 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));
}
......
......@@ -21,26 +21,32 @@ public static function getInfo() {
}
/**
* 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);
}
}
......
......@@ -178,7 +178,7 @@ protected function actions(array $form, array &$form_state) {
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);
......
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