Commit 11495979 authored by alexpott's avatar alexpott

Issue #2041423 by yched: Rely on 'provider' instead of 'module' for Field plugin types.

parent 9dd98eaa
...@@ -190,7 +190,7 @@ public function invokeFieldItemPrepareCache(EntityInterface $entity) { ...@@ -190,7 +190,7 @@ public function invokeFieldItemPrepareCache(EntityInterface $entity) {
// of making LegacyConfigFieldItem implement PrepareCacheInterface. // of making LegacyConfigFieldItem implement PrepareCacheInterface.
// @todo Remove once all core field types have been converted (see // @todo Remove once all core field types have been converted (see
// http://drupal.org/node/2014671). // http://drupal.org/node/2014671).
|| (is_subclass_of($type_definition['class'], '\Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem') && function_exists($type_definition['module'] . '_field_load'))) { || (is_subclass_of($type_definition['class'], '\Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem') && function_exists($type_definition['provider'] . '_field_load'))) {
// Call the prepareCache() method directly on each item // Call the prepareCache() method directly on each item
// individually. // individually.
...@@ -211,7 +211,7 @@ public function invokeFieldItemPrepareCache(EntityInterface $entity) { ...@@ -211,7 +211,7 @@ public function invokeFieldItemPrepareCache(EntityInterface $entity) {
if (is_subclass_of($type_definition['class'], '\Drupal\Core\Entity\Field\PrepareCacheInterface') if (is_subclass_of($type_definition['class'], '\Drupal\Core\Entity\Field\PrepareCacheInterface')
// @todo Remove once all core field types have been converted // @todo Remove once all core field types have been converted
// (see http://drupal.org/node/2014671). // (see http://drupal.org/node/2014671).
|| (is_subclass_of($type_definition['class'], '\Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem') && function_exists($type_definition['module'] . '_field_load'))) { || (is_subclass_of($type_definition['class'], '\Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem') && function_exists($type_definition['provider'] . '_field_load'))) {
// Create the items object. // Create the items object.
$items = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array(); $items = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array();
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "datetime_default", * id = "datetime_default",
* module = "datetime",
* label = @Translation("Default"), * label = @Translation("Default"),
* field_types = { * field_types = {
* "datetime" * "datetime"
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "datetime_plain", * id = "datetime_plain",
* module = "datetime",
* label = @Translation("Plain"), * label = @Translation("Plain"),
* field_types = { * field_types = {
* "datetime" * "datetime"
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "email_mailto", * id = "email_mailto",
* module = "email",
* label = @Translation("Email"), * label = @Translation("Email"),
* field_types = { * field_types = {
* "email" * "email"
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "entity_reference_entity_view", * id = "entity_reference_entity_view",
* module = "entity_reference",
* label = @Translation("Rendered entity"), * label = @Translation("Rendered entity"),
* description = @Translation("Display the referenced entities rendered by entity_view()."), * description = @Translation("Display the referenced entities rendered by entity_view()."),
* field_types = { * field_types = {
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "entity_reference_entity_id", * id = "entity_reference_entity_id",
* module = "entity_reference",
* label = @Translation("Entity ID"), * label = @Translation("Entity ID"),
* description = @Translation("Display the ID of the referenced entities."), * description = @Translation("Display the ID of the referenced entities."),
* field_types = { * field_types = {
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "entity_reference_label", * id = "entity_reference_label",
* module = "entity_reference",
* label = @Translation("Label"), * label = @Translation("Label"),
* description = @Translation("Display the label of the referenced entities."), * description = @Translation("Display the label of the referenced entities."),
* field_types = { * field_types = {
......
...@@ -442,8 +442,8 @@ function field_sync_field_status() { ...@@ -442,8 +442,8 @@ function field_sync_field_status() {
// Set fields with missing field type or storage modules to inactive. // Set fields with missing field type or storage modules to inactive.
foreach ($fields as $uuid => &$field) { foreach ($fields as $uuid => &$field) {
// Associate field types. // Associate field types.
if (isset($field_types[$field['type']]) && ($field['module'] != $field_types[$field['type']]['module'] || !$field['active'])) { if (isset($field_types[$field['type']]) && ($field['module'] != $field_types[$field['type']]['provider'] || !$field['active'])) {
$field['module'] = $field_types[$field['type']]['module']; $field['module'] = $field_types[$field['type']]['provider'];
$field['active'] = TRUE; $field['active'] = TRUE;
$changed[$uuid] = $field; $changed[$uuid] = $field;
} }
......
...@@ -51,13 +51,6 @@ class FieldFormatter extends Plugin { ...@@ -51,13 +51,6 @@ class FieldFormatter extends Plugin {
*/ */
public $description; public $description;
/**
* The name of the module providing the formatter.
*
* @var string
*/
public $module;
/** /**
* The name of the field formatter class. * The name of the field formatter class.
* *
......
...@@ -356,7 +356,7 @@ protected function saveNew() { ...@@ -356,7 +356,7 @@ protected function saveNew() {
if (!$field_type) { if (!$field_type) {
throw new FieldException(format_string('Attempt to create a field of unknown type %type.', array('%type' => $this->type))); throw new FieldException(format_string('Attempt to create a field of unknown type %type.', array('%type' => $this->type)));
} }
$this->module = $field_type['module']; $this->module = $field_type['provider'];
$this->active = TRUE; $this->active = TRUE;
// Make sure all settings are present, so that a complete field // Make sure all settings are present, so that a complete field
......
...@@ -95,7 +95,7 @@ public function getPropertyDefinitions() { ...@@ -95,7 +95,7 @@ public function getPropertyDefinitions() {
*/ */
public static function schema(Field $field) { public static function schema(Field $field) {
$definition = \Drupal::service('plugin.manager.entity.field.field_type')->getDefinition($field->type); $definition = \Drupal::service('plugin.manager.entity.field.field_type')->getDefinition($field->type);
$module = $definition['module']; $module = $definition['provider'];
module_load_install($module); module_load_install($module);
$callback = "{$module}_field_schema"; $callback = "{$module}_field_schema";
if (function_exists($callback)) { if (function_exists($callback)) {
...@@ -161,7 +161,7 @@ public function instanceSettingsForm(array $form, array &$form_state) { ...@@ -161,7 +161,7 @@ public function instanceSettingsForm(array $form, array &$form_state) {
*/ */
protected function getLegacyCallback($hook) { protected function getLegacyCallback($hook) {
$definition = $this->getPluginDefinition(); $definition = $this->getPluginDefinition();
$module = $definition['module']; $module = $definition['provider'];
$callback = "{$module}_field_{$hook}"; $callback = "{$module}_field_{$hook}";
if (function_exists($callback)) { if (function_exists($callback)) {
return $callback; return $callback;
......
...@@ -64,7 +64,7 @@ public function getDefinitions() { ...@@ -64,7 +64,7 @@ public function getDefinitions() {
if (function_exists($function)) { if (function_exists($function)) {
foreach ($function() as $plugin_id => $definition) { foreach ($function() as $plugin_id => $definition) {
$definition['id'] = $plugin_id; $definition['id'] = $plugin_id;
$definition['module'] = $module; $definition['provider'] = $module;
$definition['list_class'] = '\Drupal\field\Plugin\field\field_type\LegacyConfigField'; $definition['list_class'] = '\Drupal\field\Plugin\field\field_type\LegacyConfigField';
$definitions[$plugin_id] = $definition; $definitions[$plugin_id] = $definition;
} }
......
...@@ -102,7 +102,7 @@ public function deleteRevision() { ...@@ -102,7 +102,7 @@ public function deleteRevision() {
*/ */
protected function legacyCallback($hook, $args = array()) { protected function legacyCallback($hook, $args = array()) {
$definition = $this->getPluginDefinition(); $definition = $this->getPluginDefinition();
$module = $definition['module']; $module = $definition['provider'];
$callback = "{$module}_field_{$hook}"; $callback = "{$module}_field_{$hook}";
if (function_exists($callback)) { if (function_exists($callback)) {
$entity = $this->getParent(); $entity = $this->getParent();
......
...@@ -31,7 +31,7 @@ abstract class LegacyConfigFieldItem extends ConfigFieldItemBase implements Prep ...@@ -31,7 +31,7 @@ abstract class LegacyConfigFieldItem extends ConfigFieldItemBase implements Prep
*/ */
public static function schema(Field $field) { public static function schema(Field $field) {
$definition = \Drupal::service('plugin.manager.entity.field.field_type')->getDefinition($field->type); $definition = \Drupal::service('plugin.manager.entity.field.field_type')->getDefinition($field->type);
$module = $definition['module']; $module = $definition['provider'];
module_load_install($module); module_load_install($module);
$callback = "{$module}_field_schema"; $callback = "{$module}_field_schema";
if (function_exists($callback)) { if (function_exists($callback)) {
...@@ -118,7 +118,7 @@ public function prepareCache() { ...@@ -118,7 +118,7 @@ public function prepareCache() {
*/ */
protected function getLegacyCallback($hook) { protected function getLegacyCallback($hook) {
$definition = $this->getPluginDefinition(); $definition = $this->getPluginDefinition();
$module = $definition['module']; $module = $definition['provider'];
$callback = "{$module}_field_{$hook}"; $callback = "{$module}_field_{$hook}";
if (function_exists($callback)) { if (function_exists($callback)) {
return $callback; return $callback;
......
...@@ -29,7 +29,7 @@ function testFieldInfo() { ...@@ -29,7 +29,7 @@ function testFieldInfo() {
foreach ($field_type as $key => $val) { foreach ($field_type as $key => $val) {
$this->assertEqual($info[$t_key][$key], $val, format_string('Field type %t_key key %key is %value', array('%t_key' => $t_key, '%key' => $key, '%value' => print_r($val, TRUE)))); $this->assertEqual($info[$t_key][$key], $val, format_string('Field type %t_key key %key is %value', array('%t_key' => $t_key, '%key' => $key, '%value' => print_r($val, TRUE))));
} }
$this->assertEqual($info[$t_key]['module'], 'field_test', 'Field type field_test module appears.'); $this->assertEqual($info[$t_key]['provider'], 'field_test', 'Field type field_test module appears.');
} }
$storage_info = field_test_field_storage_info(); $storage_info = field_test_field_storage_info();
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "field_test_default", * id = "field_test_default",
* module = "field_test",
* label = @Translation("Default"), * label = @Translation("Default"),
* description = @Translation("Default formatter"), * description = @Translation("Default formatter"),
* field_types = { * field_types = {
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "field_empty_test", * id = "field_empty_test",
* module = "field_test",
* label = @Translation("Field empty test"), * label = @Translation("Field empty test"),
* field_types = { * field_types = {
* "test_field", * "test_field",
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "field_test_multiple", * id = "field_test_multiple",
* module = "field_test",
* label = @Translation("Multiple"), * label = @Translation("Multiple"),
* description = @Translation("Multiple formatter"), * description = @Translation("Multiple formatter"),
* field_types = { * field_types = {
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "field_test_with_prepare_view", * id = "field_test_with_prepare_view",
* module = "field_test",
* label = @Translation("With prepare step"), * label = @Translation("With prepare step"),
* description = @Translation("Tests prepareView() method"), * description = @Translation("Tests prepareView() method"),
* field_types = { * field_types = {
......
...@@ -109,7 +109,7 @@ public function buildRow(EntityInterface $entity) { ...@@ -109,7 +109,7 @@ public function buildRow(EntityInterface $entity) {
} }
$field_type = $this->fieldTypes[$entity->getFieldType()]; $field_type = $this->fieldTypes[$entity->getFieldType()];
$row['data']['type'] = t('@type (module: @module)', array('@type' => $field_type['label'], '@module' => $field_type['module'])); $row['data']['type'] = t('@type (module: @module)', array('@type' => $field_type['label'], '@module' => $field_type['provider']));
$usage = array(); $usage = array();
foreach($this->fieldInfo[$entity->id()]['bundles'] as $entity_type => $field_bundles) { foreach($this->fieldInfo[$entity->id()]['bundles'] as $entity_type => $field_bundles) {
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "file_default", * id = "file_default",
* module = "file",
* label = @Translation("Generic file"), * label = @Translation("Generic file"),
* field_types = { * field_types = {
* "file" * "file"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "file_rss_enclosure", * id = "file_rss_enclosure",
* module = "file",
* label = @Translation("RSS enclosure"), * label = @Translation("RSS enclosure"),
* field_types = { * field_types = {
* "file" * "file"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "file_table", * id = "file_table",
* module = "file",
* label = @Translation("Table of files"), * label = @Translation("Table of files"),
* field_types = { * field_types = {
* "file" * "file"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "file_url_plain", * id = "file_url_plain",
* module = "file",
* label = @Translation("URL to file"), * label = @Translation("URL to file"),
* field_types = { * field_types = {
* "file" * "file"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "image", * id = "image",
* module = "image",
* label = @Translation("Image"), * label = @Translation("Image"),
* field_types = { * field_types = {
* "image" * "image"
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "link", * id = "link",
* module = "link",
* label = @Translation("Link"), * label = @Translation("Link"),
* field_types = { * field_types = {
* "link" * "link"
......
...@@ -16,14 +16,12 @@ ...@@ -16,14 +16,12 @@
use Drupal\Core\Annotation\Translation; use Drupal\Core\Annotation\Translation;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Field\FieldInterface; use Drupal\Core\Entity\Field\FieldInterface;
use Drupal\field\Plugin\Type\Formatter\FormatterBase;
/** /**
* Plugin implementation of the 'link_separate' formatter. * Plugin implementation of the 'link_separate' formatter.
* *
* @FieldFormatter( * @FieldFormatter(
* id = "link_separate", * id = "link_separate",
* module = "link",
* label = @Translation("Separate link text and URL"), * label = @Translation("Separate link text and URL"),
* field_types = { * field_types = {
* "link" * "link"
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "number_decimal", * id = "number_decimal",
* module = "number",
* label = @Translation("Default"), * label = @Translation("Default"),
* field_types = { * field_types = {
* "number_decimal", * "number_decimal",
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "number_integer", * id = "number_integer",
* module = "number",
* label = @Translation("Default"), * label = @Translation("Default"),
* field_types = { * field_types = {
* "number_integer" * "number_integer"
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "number_unformatted", * id = "number_unformatted",
* module = "number",
* label = @Translation("Unformatted"), * label = @Translation("Unformatted"),
* field_types = { * field_types = {
* "number_integer", * "number_integer",
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "list_default", * id = "list_default",
* module = "options",
* label = @Translation("Default"), * label = @Translation("Default"),
* field_types = { * field_types = {
* "list_integer", * "list_integer",
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "list_key", * id = "list_key",
* module = "options",
* label = @Translation("Key"), * label = @Translation("Key"),
* field_types = { * field_types = {
* "list_integer", * "list_integer",
......
...@@ -116,7 +116,7 @@ protected function getOptions() { ...@@ -116,7 +116,7 @@ protected function getOptions() {
// Get the list of options from the field type module, and sanitize them. // Get the list of options from the field type module, and sanitize them.
$field_type_info = field_info_field_types($this->fieldDefinition->getFieldType()); $field_type_info = field_info_field_types($this->fieldDefinition->getFieldType());
$module = $field_type_info['module']; $module = $field_type_info['provider'];
$options = (array) $module_handler->invoke($module, 'options_list', array($this->fieldDefinition, $this->entity)); $options = (array) $module_handler->invoke($module, 'options_list', array($this->fieldDefinition, $this->entity));
// Add an empty option if the widget needs one. // Add an empty option if the widget needs one.
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "picture", * id = "picture",
* module = "picture",
* label = @Translation("Picture"), * label = @Translation("Picture"),
* field_types = { * field_types = {
* "image", * "image",
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "entity_reference_rss_category", * id = "entity_reference_rss_category",
* module = "taxonomy",
* label = @Translation("RSS category"), * label = @Translation("RSS category"),
* description = @Translation("Display reference to taxonomy term in RSS."), * description = @Translation("Display reference to taxonomy term in RSS."),
* field_types = { * field_types = {
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "taxonomy_term_reference_link", * id = "taxonomy_term_reference_link",
* module = "taxonomy",
* label = @Translation("Link"), * label = @Translation("Link"),
* field_types = { * field_types = {
* "taxonomy_term_reference" * "taxonomy_term_reference"
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
use Drupal\Core\Annotation\Translation; use Drupal\Core\Annotation\Translation;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Field\FieldInterface; use Drupal\Core\Entity\Field\FieldInterface;
use Drupal\field\Plugin\Type\Formatter\FormatterBase;
use Drupal\taxonomy\Plugin\field\formatter\TaxonomyFormatterBase; use Drupal\taxonomy\Plugin\field\formatter\TaxonomyFormatterBase;
/** /**
...@@ -19,7 +18,6 @@ ...@@ -19,7 +18,6 @@
* *
* @FieldFormatter( * @FieldFormatter(
* id = "taxonomy_term_reference_plain", * id = "taxonomy_term_reference_plain",
* module = "taxonomy",
* label = @Translation("Plain text"), * label = @Translation("Plain text"),
* field_types = { * field_types = {
* "taxonomy_term_reference"