Issue #2408667 by pguillard, mpdonadio, marvin_B8, Xano, geertvd, lomasr, dawehner, yched: Rename Field.php to EntityField.php

8.3.x
Nathaniel Catchpole 2016-10-21 13:57:58 +01:00
parent 5c9d1a92f1
commit bf42d739aa
10 changed files with 1129 additions and 1118 deletions

View File

@ -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 @@ use Drupal\views\ResultRow;
*
* @ViewsField("comment_depth")
*/
class Depth extends Field {
class Depth extends EntityField {
/**
* {@inheritdoc}

View File

@ -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 @@ use Drupal\views\ResultRow;
*
* @ViewsField("term_name")
*/
class TermName extends Field {
class TermName extends EntityField {
/**
* {@inheritdoc}

View File

@ -7,7 +7,7 @@ use Drupal\Core\Entity\Entity\EntityViewDisplay;
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 @@ class EntityFieldRenderer extends RendererBase {
*
* @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 @@ class EntityFieldRenderer extends RendererBase {
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;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@ use Drupal\field\Entity\FieldStorageConfig;
/**
* 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
*/

View File

@ -35,11 +35,11 @@ class EntityViewsDataUpdateTest extends UpdatePathTestBase {
$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.

View File

@ -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 @@ trait ViewResultAssertionTrait {
// 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];

View File

@ -8,7 +8,7 @@ use Drupal\entity_test\Entity\EntityTestRev;
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 @@ use Drupal\views\Views;
/**
* 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 @@ class FieldFieldTest extends ViewsKernelTestBase {
$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 @@ class FieldFieldTest extends ViewsKernelTestBase {
$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 @@ class FieldFieldTest extends ViewsKernelTestBase {
$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 @@ class FieldFieldTest extends ViewsKernelTestBase {
$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 @@ class FieldFieldTest extends ViewsKernelTestBase {
$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 @@ class FieldFieldTest extends ViewsKernelTestBase {
}
/**
* Tests \Drupal\views\Plugin\views\field\Field::getValue
* Tests \Drupal\views\Plugin\views\field\EntityField::getValue
*/
public function testGetValueMethod() {
$bundle = 'test_bundle';

View File

@ -10,12 +10,12 @@ namespace Drupal\Tests\views\Unit\Plugin\field;
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 @@ class FieldTest extends UnitTestCase {
// 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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
'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 @@ class FieldTest extends UnitTestCase {
/**
* 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 @@ class FieldTest extends UnitTestCase {
}
class FieldTestField extends Field {
class FieldTestEntityField extends EntityField {
public function executePrepareItemsByDelta(array $all_values) {
return $this->prepareItemsByDelta($all_values);