Commit 06bed5c7 authored by webchick's avatar webchick

Issue #2399931 by dawehner, yched: Generic entity api field handler should...

Issue #2399931 by dawehner, yched: Generic entity api field handler should live in views module not in field module
parent 082b123f
......@@ -11,7 +11,7 @@
* Implements hook_field_views_data().
*/
function entity_reference_field_views_data(FieldStorageConfigInterface $field_storage) {
$data = field_views_field_default_views_data($field_storage);
$data = views_field_default_views_data($field_storage);
$entity_manager = \Drupal::entityManager();
$table_mapping = $entity_manager->getStorage($field_storage->getTargetEntityTypeId())->getTableMapping();
foreach ($data as $table_name => $table_data) {
......
......@@ -264,20 +264,6 @@ function _field_create_entity_from_ids($ids) {
return entity_create($ids->entity_type, $id_properties);
}
/**
* Implements hook_hook_info().
*/
function field_hook_info() {
$hooks['field_views_data'] = array(
'group' => 'views',
);
$hooks['field_views_data_alter'] = array(
'group' => 'views',
);
return $hooks;
}
/**
* Implements hook_config_import_steps_alter().
*/
......
This diff is collapsed.
......@@ -13,10 +13,10 @@
* Views integration for file fields. Adds a file relationship to the default
* field data.
*
* @see field_views_field_default_views_data()
* @see views_field_default_views_data()
*/
function file_field_views_data(FieldStorageConfigInterface $field_storage) {
$data = field_views_field_default_views_data($field_storage);
$data = views_field_default_views_data($field_storage);
foreach ($data as $table_name => $table_data) {
// Add the relationship only on the fid field.
$data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = array(
......@@ -45,7 +45,7 @@ function file_field_views_data_views_data_alter(array &$data, FieldStorageConfig
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = $entity_manager->getStorage($entity_type_id)->getTableMapping();
list($label) = field_views_field_label($entity_type_id, $field_name);
list($label) = views_entity_field_label($entity_type_id, $field_name);
$data['file_managed'][$pseudo_field_name]['relationship'] = array(
'title' => t('@entity using @field', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
......
......@@ -13,10 +13,10 @@
* Views integration for image fields. Adds an image relationship to the default
* field data.
*
* @see field_views_field_default_views_data()
* @see views_field_default_views_data()
*/
function image_field_views_data(FieldStorageConfigInterface $field_storage) {
$data = field_views_field_default_views_data($field_storage);
$data = views_field_default_views_data($field_storage);
foreach ($data as $table_name => $table_data) {
// Add the relationship only on the target_id field.
$data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = array(
......@@ -44,7 +44,7 @@ function image_field_views_data_views_data_alter(array &$data, FieldStorageConfi
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = $entity_manager->getStorage($entity_type_id)->getTableMapping();
list($label) = field_views_field_label($entity_type_id, $field_name);
list($label) = views_entity_field_label($entity_type_id, $field_name);
$data['file_managed'][$pseudo_field_name]['relationship'] = array(
'title' => t('@entity using @field', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
......
......@@ -57,10 +57,10 @@ function taxonomy_views_data_alter(&$data) {
* Views integration for taxonomy_term_reference fields. Adds a term relationship to the default
* field data.
*
* @see field_views_field_default_views_data()
* @see views_field_default_views_data()
*/
function taxonomy_field_views_data(FieldStorageConfigInterface $field_storage) {
$data = field_views_field_default_views_data($field_storage);
$data = views_field_default_views_data($field_storage);
foreach ($data as $table_name => $table_data) {
foreach ($table_data as $field_name => $field_data) {
if (isset($field_data['filter']) && $field_name != 'delta') {
......@@ -98,7 +98,7 @@ function taxonomy_field_views_data_views_data_alter(array &$data, FieldStorageCo
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = $entity_manager->getStorage($entity_type_id)->getTableMapping();
list($label) = field_views_field_label($entity_type_id, $field_name);
list($label) = views_entity_field_label($entity_type_id, $field_name);
$data['taxonomy_term_data'][$pseudo_field_name]['relationship'] = array(
'title' => t('@entity using @field', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
......
......@@ -2,10 +2,10 @@
/**
* @file
* Definition of views_handler_argument_field_list.
* Contains \Drupal\views\Plugin\views\argument\FieldList.
*/
namespace Drupal\field\Plugin\views\argument;
namespace Drupal\views\Plugin\views\argument;
use Drupal\Component\Utility\String;
use Drupal\Core\Field\AllowedTagsXssTrait;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Definition of Drupal\field\Plugin\views\argument\ListString.
* Contains \Drupal\views\Plugin\views\argument\ListString.
*/
namespace Drupal\field\Plugin\views\argument;
namespace Drupal\views\Plugin\views\argument;
use Drupal\Component\Utility\String as UtilityString;
use Drupal\Core\Field\AllowedTagsXssTrait;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Definition of Drupal\field\Plugin\views\field\Field.
* Contains \Drupal\views\Plugin\views\field\Field.
*/
namespace Drupal\field\Plugin\views\field;
namespace Drupal\views\Plugin\views\field;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Xss;
......
......@@ -2,12 +2,10 @@
/**
* @file
* Definition of Drupal\field\Plugin\views\filter\FieldList.
* Contains \Drupal\views\Plugin\views\filter\FieldList.
*/
namespace Drupal\field\Plugin\views\filter;
use Drupal\views\Plugin\views\filter\ManyToOne;
namespace Drupal\views\Plugin\views\filter;
/**
* Filter handler which uses list-fields as options.
......
......@@ -2,10 +2,10 @@
/**
* @file
* Definition of Drupal\field\Plugin\views\relationship\EntityReverse.
* Contains \Drupal\views\Plugin\views\relationship\EntityReverse.
*/
namespace Drupal\field\Plugin\views\relationship;
namespace Drupal\views\Plugin\views\relationship;
use Drupal\views\Plugin\ViewsHandlerManager;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
......
......@@ -431,7 +431,7 @@ function hook_views_data_alter(array &$data) {
* in other modules.
*
* If no hook implementation exists, hook_views_data() falls back to
* field_views_field_default_views_data().
* views_field_default_views_data().
*
* @param \Drupal\field\FieldStorageConfigInterface $field_storage
* The field storage config entity.
......@@ -440,12 +440,12 @@ function hook_views_data_alter(array &$data) {
* An array of views data, in the same format as the return value of
* hook_views_data().
*
* @see field_views_data()
* @see views_views_data()
* @see hook_field_views_data_alter()
* @see hook_field_views_data_views_data_alter()
*/
function hook_field_views_data(\Drupal\field\FieldStorageConfigInterface $field_storage) {
$data = field_views_field_default_views_data($field_storage);
$data = views_field_default_views_data($field_storage);
foreach ($data as $table_name => $table_data) {
// Add the relationship only on the target_id field.
$data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = array(
......@@ -464,7 +464,7 @@ function hook_field_views_data(\Drupal\field\FieldStorageConfigInterface $field_
*
* This is called on all modules even if there is no hook_field_views_data()
* implementation for the field, and therefore may be used to alter the
* default data that field_views_field_default_views_data() supplies for the
* default data that views_field_default_views_data() supplies for the
* field storage.
*
* @param array $data
......@@ -473,7 +473,7 @@ function hook_field_views_data(\Drupal\field\FieldStorageConfigInterface $field_
* @param \Drupal\field\FieldStorageConfigInterface $field_storage
* The field storage config entity.
*
* @see field_views_data()
* @see views_views_data()
* @see hook_field_views_data()
* @see hook_field_views_data_views_data_alter()
*/
......@@ -484,7 +484,7 @@ function hook_field_views_data_alter(array &$data, \Drupal\field\FieldStorageCon
$pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id;
$table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping();
list($label) = field_views_field_label($entity_type_id, $field_name);
list($label) = views_entity_field_label($entity_type_id, $field_name);
$data['file_managed'][$pseudo_field_name]['relationship'] = array(
'title' => t('@entity using @field', array('@entity' => $entity_type->getLabel(), '@field' => $label)),
......@@ -531,7 +531,7 @@ function hook_field_views_data_alter(array &$data, \Drupal\field\FieldStorageCon
*
* @see hook_field_views_data()
* @see hook_field_views_data_alter()
* @see field_views_data_alter()
* @see views_views_data_alter()
*/
function hook_field_views_data_views_data_alter(array &$data, \Drupal\field\FieldStorageConfigInterface $field) {
$field_name = $field->getName();
......@@ -539,7 +539,7 @@ function hook_field_views_data_views_data_alter(array &$data, \Drupal\field\Fiel
$entity_type_id = $field->entity_type;
$entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
$pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id;
list($label) = field_views_field_label($entity_type_id, $field_name);
list($label) = views_entity_field_label($entity_type_id, $field_name);
$table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping();
// Views data for this field is in $data[$data_key].
......
......@@ -593,6 +593,13 @@ function views_hook_info() {
'views_query_alter',
), array('group' => 'views_execution'));
$hooks['field_views_data'] = array(
'group' => 'views',
);
$hooks['field_views_data_alter'] = array(
'group' => 'views',
);
return $hooks;
}
......
This diff is collapsed.
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