Commit bf42d739 authored by catch's avatar catch

Issue #2408667 by pguillard, mpdonadio, marvin_B8, Xano, geertvd, lomasr,...

Issue #2408667 by pguillard, mpdonadio, marvin_B8, Xano, geertvd, lomasr, dawehner, yched: Rename Field.php to EntityField.php
parent 5c9d1a92
......@@ -2,7 +2,7 @@
namespace Drupal\comment\Plugin\views\field;
use Drupal\views\Plugin\views\field\Field;
use Drupal\views\Plugin\views\field\EntityField;
use Drupal\views\ResultRow;
/**
......@@ -12,7 +12,7 @@
*
* @ViewsField("comment_depth")
*/
class Depth extends Field {
class Depth extends EntityField {
/**
* {@inheritdoc}
......
......@@ -3,7 +3,7 @@
namespace Drupal\taxonomy\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\field\Field;
use Drupal\views\Plugin\views\field\EntityField;
use Drupal\views\ResultRow;
/**
......@@ -13,7 +13,7 @@
*
* @ViewsField("term_name")
*/
class TermName extends Field {
class TermName extends EntityField {
/**
* {@inheritdoc}
......
......@@ -7,7 +7,7 @@
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\views\Plugin\views\field\Field;
use Drupal\views\Plugin\views\field\EntityField;
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
......@@ -111,13 +111,13 @@ public function query(QueryPluginBase $query, $relationship = NULL) {
*
* @param \Drupal\views\ResultRow $row
* A single row of the query result.
* @param \Drupal\views\Plugin\views\field\Field $field
* @param \Drupal\views\Plugin\views\field\EntityField $field
* (optional) A field to be rendered.
*
* @return array
* A renderable array for the entity data contained in the result row.
*/
public function render(ResultRow $row, Field $field = NULL) {
public function render(ResultRow $row, EntityField $field = NULL) {
// The method is called for each field in each result row. In order to
// leverage multiple-entity building of formatter output, we build the
// render arrays for all fields in all rows on the first call.
......@@ -259,7 +259,7 @@ protected function buildFields(array $values) {
protected function getRenderableFieldIds() {
$field_ids = [];
foreach ($this->view->field as $field_id => $field) {
if ($field instanceof Field && $field->relationship == $this->relationship) {
if ($field instanceof EntityField && $field->relationship == $this->relationship) {
$field_ids[] = $field_id;
}
}
......
This diff is collapsed.
......@@ -11,7 +11,7 @@
/**
* Tests the "Display all values in the same row" setting.
*
* @see \Drupal\views\Plugin\views\field\Field
* @see \Drupal\views\Plugin\views\field\EntityField
*
* @group views
*/
......
......@@ -35,11 +35,11 @@ public function testUpdateHookN() {
$view->initHandlers();
// Extract the fields from the test view that were updated.
/** @var \Drupal\views\Plugin\views\field\Field $field */
/** @var \Drupal\views\Plugin\views\field\EntityField $field */
$created = $view->field['created'];
/** @var \Drupal\views\Plugin\views\field\Field $field */
/** @var \Drupal\views\Plugin\views\field\EntityField $field */
$created_1 = $view->field['created_1'];
/** @var \Drupal\views\Plugin\views\field\Field $field */
/** @var \Drupal\views\Plugin\views\field\EntityField $field */
$created_2 = $view->field['created_2'];
// Make sure the plugins were converted from date to field.
......
......@@ -2,7 +2,7 @@
namespace Drupal\views\Tests;
use Drupal\views\Plugin\views\field\Field;
use Drupal\views\Plugin\views\field\EntityField;
/**
* Provides a class for assertions to check for the expected result of a View.
......@@ -91,7 +91,7 @@ protected function assertIdenticalResultsetHelper($view, $expected_result, $colu
// The comparison will be done on the string representation of the value.
// For entity fields we don't have the raw value. Let's try to fetch it
// using the entity itself.
elseif (empty($value->$view_column) && isset($view->field[$expected_column]) && ($field = $view->field[$expected_column]) && $field instanceof Field) {
elseif (empty($value->$view_column) && isset($view->field[$expected_column]) && ($field = $view->field[$expected_column]) && $field instanceof EntityField) {
$column = NULL;
if (count(explode(':', $view_column)) == 2) {
$column = explode(':', $view_column)[1];
......
......@@ -8,7 +8,7 @@
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\user\Entity\User;
use Drupal\views\Plugin\views\field\Field;
use Drupal\views\Plugin\views\field\EntityField;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Views;
......@@ -16,7 +16,7 @@
/**
* Provides some integration tests for the Field handler.
*
* @see \Drupal\views\Plugin\views\field\Field
* @see \Drupal\views\Plugin\views\field\EntityField
* @group views
*/
class FieldFieldTest extends ViewsKernelTestBase {
......@@ -229,8 +229,8 @@ public function testSimpleExecute() {
$executable = Views::getView('test_field_field_test');
$executable->execute();
$this->assertTrue($executable->field['id'] instanceof Field);
$this->assertTrue($executable->field['field_test'] instanceof Field);
$this->assertTrue($executable->field['id'] instanceof EntityField);
$this->assertTrue($executable->field['field_test'] instanceof EntityField);
$this->assertIdenticalResultset($executable,
[
......@@ -299,9 +299,9 @@ public function testFieldAlias() {
$executable = Views::getView('test_field_alias_test');
$executable->execute();
$this->assertTrue($executable->field['id'] instanceof Field);
$this->assertTrue($executable->field['name'] instanceof Field);
$this->assertTrue($executable->field['name_alias'] instanceof Field);
$this->assertTrue($executable->field['id'] instanceof EntityField);
$this->assertTrue($executable->field['name'] instanceof EntityField);
$this->assertTrue($executable->field['name_alias'] instanceof EntityField);
$this->assertIdenticalResultset($executable,
[
......@@ -348,10 +348,10 @@ public function testComplexExecute() {
$timezones[] = $user->getTimeZone();
}
$this->assertTrue($executable->field['field_test_multiple'] instanceof Field);
$this->assertTrue($executable->field['field_test_multiple_1'] instanceof Field);
$this->assertTrue($executable->field['field_test_multiple_2'] instanceof Field);
$this->assertTrue($executable->field['timezone'] instanceof Field);
$this->assertTrue($executable->field['field_test_multiple'] instanceof EntityField);
$this->assertTrue($executable->field['field_test_multiple_1'] instanceof EntityField);
$this->assertTrue($executable->field['field_test_multiple_2'] instanceof EntityField);
$this->assertTrue($executable->field['timezone'] instanceof EntityField);
$this->assertIdenticalResultset($executable,
[
......@@ -421,8 +421,8 @@ public function testRevisionExecute() {
$executable = Views::getView('test_field_field_revision_test');
$executable->execute();
$this->assertTrue($executable->field['name'] instanceof Field);
$this->assertTrue($executable->field['field_test'] instanceof Field);
$this->assertTrue($executable->field['name'] instanceof EntityField);
$this->assertTrue($executable->field['field_test'] instanceof EntityField);
$this->assertIdenticalResultset($executable,
[
......@@ -475,12 +475,12 @@ public function testRevisionComplexExecute() {
$timezones[] = $user->getTimeZone();
}
$this->assertTrue($executable->field['id'] instanceof Field);
$this->assertTrue($executable->field['revision_id'] instanceof Field);
$this->assertTrue($executable->field['timezone'] instanceof Field);
$this->assertTrue($executable->field['field_test_multiple'] instanceof Field);
$this->assertTrue($executable->field['field_test_multiple_1'] instanceof Field);
$this->assertTrue($executable->field['field_test_multiple_2'] instanceof Field);
$this->assertTrue($executable->field['id'] instanceof EntityField);
$this->assertTrue($executable->field['revision_id'] instanceof EntityField);
$this->assertTrue($executable->field['timezone'] instanceof EntityField);
$this->assertTrue($executable->field['field_test_multiple'] instanceof EntityField);
$this->assertTrue($executable->field['field_test_multiple_1'] instanceof EntityField);
$this->assertTrue($executable->field['field_test_multiple_2'] instanceof EntityField);
$this->assertIdenticalResultset($executable,
[
......@@ -551,7 +551,7 @@ public function testMissingBundleFieldRender() {
}
/**
* Tests \Drupal\views\Plugin\views\field\Field::getValue
* Tests \Drupal\views\Plugin\views\field\EntityField::getValue
*/
public function testGetValueMethod() {
$bundle = 'test_bundle';
......
......@@ -10,12 +10,12 @@
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Tests\UnitTestCase;
use Drupal\Tests\views\Unit\Plugin\HandlerTestTrait;
use Drupal\views\Plugin\views\field\Field;
use Drupal\views\Plugin\views\field\EntityField;
use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* @coversDefaultClass \Drupal\views\Plugin\views\field\Field
* @coversDefaultClass \Drupal\views\Plugin\views\field\EntityField
* @group views
*/
class FieldTest extends UnitTestCase {
......@@ -107,7 +107,7 @@ public function testConstruct() {
// provides it.
'entity field' => 'title',
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$this->assertEquals('title', $handler->definition['field_name']);
}
......@@ -120,7 +120,7 @@ public function testDefineOptionsWithNoOptions() {
'entity_type' => 'test_entity',
'field_name' => 'title'
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
// Setup the entity manager to allow fetching the storage definitions.
$title_storage = $this->getBaseFieldStorage();
......@@ -149,7 +149,7 @@ public function testDefineOptionsWithDefaultFormatterOnFieldDefinition() {
'default_formatter' => 'test_example',
'default_formatter_settings' => ['link_to_entity' => TRUE]
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
// Setup the entity manager to allow fetching the storage definitions.
$title_storage = $this->getBaseFieldStorage();
......@@ -176,7 +176,7 @@ public function testDefineOptionsWithDefaultFormatterOnFieldType() {
'field_name' => 'title',
'default_formatter_settings' => ['link_to_entity' => TRUE]
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
// Setup the entity manager to allow fetching the storage definitions.
$title_storage = $this->getBaseFieldStorage();
......@@ -202,7 +202,7 @@ public function testCalculateDependenciesWithBaseField() {
'entity_type' => 'test_entity',
'field_name' => 'title'
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$title_storage = $this->getBaseFieldStorage();
$this->entityManager->expects($this->atLeastOnce())
......@@ -224,7 +224,7 @@ public function testCalculateDependenciesWithConfiguredField() {
'entity_type' => 'test_entity',
'field_name' => 'body'
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$body_storage = $this->getConfigFieldStorage();
$this->entityManager->expects($this->atLeastOnce())
......@@ -250,7 +250,7 @@ public function testAccess() {
'entity_type' => 'test_entity',
'field_name' => 'title',
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler->view = $this->executable;
$handler->setViewsData($this->viewsData);
......@@ -301,7 +301,7 @@ public function testClickSortWithOutConfiguredColumn($order) {
'entity_type' => 'test_entity',
'field_name' => 'title',
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler->view = $this->executable;
$this->entityManager->expects($this->never())
......@@ -323,7 +323,7 @@ public function testClickSortWithBaseField($order) {
'entity_type' => 'test_entity',
'field_name' => 'title',
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler->view = $this->executable;
$field_storage = $this->getBaseFieldStorage();
......@@ -383,7 +383,7 @@ public function testClickSortWithConfiguredField($order) {
'entity_type' => 'test_entity',
'field_name' => 'body',
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler->view = $this->executable;
$field_storage = $this->getConfigFieldStorage();
......@@ -438,7 +438,7 @@ public function testQueryWithGroupByForBaseField() {
'entity_type' => 'test_entity',
'field_name' => 'title',
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler->view = $this->executable;
$handler->view->field = [$handler];
......@@ -500,7 +500,7 @@ public function testQueryWithGroupByForConfigField() {
'entity_type' => 'test_entity',
'field_name' => 'body',
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new EntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler->view = $this->executable;
$handler->view->field = [$handler];
......@@ -564,7 +564,7 @@ public function testPrepareItemsByDelta(array $options, array $expected_values)
'entity_type' => 'test_entity',
'field_name' => 'integer',
];
$handler = new FieldTestField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler = new FieldTestEntityField([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler->view = $this->executable;
$handler->view->field = [$handler];
......@@ -688,12 +688,12 @@ public function providerSortOrders() {
/**
* Setup the mock data needed to make language renderers work.
*
* @param \Drupal\views\Plugin\views\field\Field $handler
* @param \Drupal\views\Plugin\views\field\EntityField $handler
* The field handler.
* @param $definition
* An array with entity type definition data.
*/
protected function setupLanguageRenderer(Field $handler, $definition) {
protected function setupLanguageRenderer(EntityField $handler, $definition) {
$display_handler = $this->getMockBuilder('\Drupal\views\Plugin\views\display\DisplayPluginBase')
->disableOriginalConstructor()
->getMock();
......@@ -724,7 +724,7 @@ protected function setupLanguageRenderer(Field $handler, $definition) {
}
class FieldTestField extends Field {
class FieldTestEntityField extends EntityField {
public function executePrepareItemsByDelta(array $all_values) {
return $this->prepareItemsByDelta($all_values);
......
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