Commit 7e465a9b authored by webchick's avatar webchick

Issue #1888390 by dawehner, damiankloip, tim.plunkett: Change 'human_name()'...

Issue #1888390 by dawehner, damiankloip, tim.plunkett: Change 'human_name()' to 'label' and replace View::getHumanName() with View::label().
parent 934f83fe
......@@ -2,7 +2,7 @@ base_table: node
id: test_bulk_form
description: ''
tag: ''
human_name: form
label: form
core: 8.x
display:
default:
......
......@@ -41,7 +41,7 @@ display:
field:
title:
link_to_node: '1'
human_name: test_view_block
label: test_view_block
module: views
id: test_view_block
tag: ''
......@@ -50,7 +50,7 @@ display:
field:
title:
link_to_node: '1'
human_name: test_view_block2
label: test_view_block2
module: views
id: test_view_block2
tag: ''
......@@ -37,7 +37,7 @@ public static function getInfo() {
*/
public function testCommentWizard() {
$view = array();
$view['human_name'] = $this->randomName(16);
$view['label'] = $this->randomName(16);
$view['id'] = strtolower($this->randomName(16));
$view['show[wizard_key]'] = 'comment';
$view['page[create]'] = TRUE;
......
......@@ -58,7 +58,7 @@ display:
position: ''
display_options:
path: test-comment-rss
human_name: test_comment_rss
label: test_comment_rss
module: views
id: test_comment_rss
tag: ''
......@@ -44,6 +44,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: test_comment_user_uid
label: test_comment_user_uid
id: test_comment_user_uid
tag: default
......@@ -5,7 +5,7 @@ core: 8.x
module: entity_reference_test
id: test_entity_reference
description: ''
human_name: 'Entity reference'
label: 'Entity reference'
tag: ''
disabled: false
display:
......
......@@ -34,6 +34,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: test_view_fieldapi
label: test_view_fieldapi
id: test_view_fieldapi
tag: default
......@@ -148,7 +148,7 @@ display:
displays:
page_1: page_1
default: '0'
human_name: Frontpage
label: Frontpage
module: node
id: frontpage
tag: ''
......
......@@ -14,6 +14,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: ''
label: ''
id: test_field_type
tag: ''
......@@ -46,6 +46,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: test_filter_node_uid_revision
label: test_filter_node_uid_revision
id: test_filter_node_uid_revision
tag: default
......@@ -2,7 +2,7 @@ base_table: node
id: test_status_extra
description: ''
tag: ''
human_name: test_status_extra
label: test_status_extra
core: 8.x
display:
default:
......
......@@ -2,7 +2,7 @@ base_table: entity_test
id: test_serializer_display_entity
description: ''
tag: ''
human_name: 'Test serialize display entity rows'
label: 'Test serialize display entity rows'
core: 8.x
display:
default:
......
......@@ -2,7 +2,7 @@ base_table: views_test_data
id: test_serializer_display_field
description: ''
tag: ''
human_name: 'Test serializer display field rows'
label: 'Test serializer display field rows'
core: 8.x
display:
default:
......
......@@ -232,7 +232,7 @@ display:
position: ''
display_options:
path: test_statistics_integration
human_name: 'Test statistics integration'
label: 'Test statistics integration'
module: views
id: test_statistics_integration
tag: ''
......@@ -62,7 +62,7 @@ display:
display_title: Master
id: default
position: { }
human_name: test_groupwise
label: test_groupwise
langcode: und
module: views
id: test_groupwise_term
......
......@@ -71,6 +71,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: test_taxonomy_node_term_data
label: test_taxonomy_node_term_data
id: test_taxonomy_node_term_data
tag: ''
......@@ -95,7 +95,7 @@ display:
position: ''
display_options:
path: test-entity-translations-link
human_name: People
label: People
module: views
id: test_entity_translations_link
tag: ''
......@@ -23,6 +23,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: ''
label: ''
id: test_access_perm
tag: ''
......@@ -21,6 +21,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: ''
label: ''
id: test_access_role
tag: ''
......@@ -73,7 +73,7 @@ display:
display_title: Master
id: default
position: { }
human_name: test_groupwise_user
label: test_groupwise_user
langcode: und
module: views
id: test_groupwise_user
......
......@@ -50,6 +50,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: ''
label: ''
id: test_plugin_argument_default_current_user
tag: ''
......@@ -114,7 +114,7 @@ display:
field: created
order: DESC
plugin_id: date
human_name: test_user_data
label: test_user_data
module: views
id: test_user_data
tag: ''
......@@ -47,6 +47,6 @@ display:
display_title: Page
id: page_1
position: '0'
human_name: ''
label: ''
id: test_user_name
tag: ''
......@@ -99,6 +99,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: test_user_relationship
label: test_user_relationship
id: test_user_relationship
tag: default
......@@ -23,5 +23,5 @@ display:
display_title: Master
id: default
position: '0'
human_name:
label:
id: test_user_uid_argument
......@@ -32,6 +32,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: ''
label: ''
id: test_view_argument_validate_user
tag: ''
......@@ -151,6 +151,6 @@ display:
position: ''
display_options:
path: test-views-handler-field-role
human_name: test_views_handler_field_role
label: test_views_handler_field_role
id: test_views_handler_field_role
tag: ''
......@@ -45,6 +45,6 @@ display:
display_title: Master
id: default
position: '0'
human_name: test_views_handler_field_user_name
label: test_views_handler_field_user_name
id: test_views_handler_field_user_name
tag: default
......@@ -21,7 +21,7 @@ views.view.*:
label: 'Base table'
base_field:
label: 'Base field'
human_name:
label:
type: label
label: 'Human readable name'
core:
......
......@@ -101,7 +101,7 @@ display:
items_per_page: '30'
specify_validation: '1'
plugin_id: date_year_month
human_name: Archive
label: Archive
module: node
id: archive
tag: default
......
......@@ -120,7 +120,7 @@ display:
type: html_list
row:
type: fields
human_name: Backlinks
label: Backlinks
module: search
id: backlinks
tag: default
......
......@@ -129,7 +129,7 @@ display:
query:
type: views_query
options: { }
human_name: 'Recent comments'
label: 'Recent comments'
module: comment
id: comments_recent
tag: default
......
......@@ -150,7 +150,7 @@ display:
default: default
page: page_1
inherit_arguments: '0'
human_name: Glossary
label: Glossary
module: node
id: glossary
tag: default
......
......@@ -109,7 +109,7 @@ display:
type: rss
row:
type: node_rss
human_name: 'Taxonomy term'
label: 'Taxonomy term'
module: taxonomy
id: taxonomy_term
tag: default
......
......@@ -155,7 +155,7 @@ display:
menu:
type: normal
title: 'Recent posts'
human_name: Tracker
label: Tracker
module: node
id: tracker
tag: default
......
......@@ -34,7 +34,7 @@
* fieldable = FALSE,
* entity_keys = {
* "id" = "id",
* "label" = "human_name",
* "label" = "label",
* "uuid" = "uuid",
* "status" = "status"
* }
......@@ -56,6 +56,11 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
*/
public $id = NULL;
/**
* The label of the view.
*/
protected $label;
/**
* The description of the view, which is used only in the interface.
*
......@@ -73,13 +78,6 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
*/
protected $tag = '';
/**
* The human readable name of the view.
*
* @var string
*/
public $human_name = '';
/**
* The core version the view was created for.
*
......@@ -160,15 +158,15 @@ public function createDuplicate() {
}
/**
* Return the human readable name for a view.
* Overrides \Drupal\Core\Entity\Entity::label().
*
* When a certain view doesn't have a human readable name return the machine readable name.
* When a certain view doesn't have a label return the ID.
*/
public function getHumanName() {
if (!$human_name = $this->get('human_name')) {
$human_name = $this->id();
public function label($langcode = NULL) {
if (!$label = $this->get('label')) {
$label = $this->id();
}
return $human_name;
return $label;
}
/**
......@@ -361,7 +359,7 @@ public function getExportProperties() {
'description',
'status',
'display',
'human_name',
'label',
'module',
'id',
'tag',
......
......@@ -54,10 +54,10 @@ public function getDerivativeDefinitions(array $base_plugin_definition) {
if (empty($desc)) {
if ($display->display['display_title'] == $display->definition['title']) {
$desc = t('View: !view', array('!view' => $view->getHumanName()));
$desc = t('View: !view', array('!view' => $view->label()));
}
else {
$desc = t('View: !view: !display', array('!view' => $view->getHumanName(), '!display' => $display->display['display_title']));
$desc = t('View: !view: !display', array('!view' => $view->label(), '!display' => $display->display['display_title']));
}
}
$this->derivatives[$delta] = array(
......
......@@ -38,7 +38,7 @@ public function buildOptionsForm(&$form, &$form_state) {
'@start -- the initial record number in the set',
'@end -- the last record number in the set',
'@total -- the total records in the set',
'@name -- the human-readable name of the view',
'@label -- the human-readable name of the view',
'@per_page -- the number of items per page',
'@current_page -- the current page number',
'@current_record_count -- the current page record count',
......@@ -73,7 +73,7 @@ function render($empty = FALSE) {
// @TODO: Maybe use a possible is views empty functionality.
// Not every view has total_rows set, use view->result instead.
$total = isset($this->view->total_rows) ? $this->view->total_rows : count($this->view->result);
$name = check_plain($this->view->storage->getHumanName());
$label = check_plain($this->view->storage->label());
if ($per_page === 0) {
$page_count = 1;
$start = 1;
......@@ -90,7 +90,7 @@ function render($empty = FALSE) {
}
$current_record_count = ($end - $start) + 1;
// Get the search information.
$items = array('start', 'end', 'total', 'name', 'per_page', 'current_page', 'current_record_count', 'page_count');
$items = array('start', 'end', 'total', 'label', 'per_page', 'current_page', 'current_record_count', 'page_count');
$replacements = array();
foreach ($items as $item) {
$replacements["@$item"] = ${$item};
......
......@@ -1515,7 +1515,7 @@ function execute(ViewExecutable $view) {
drupal_set_message($e->getMessage(), 'error');
}
else {
throw new DatabaseExceptionWrapper(format_string('Exception in @human_name[@view_name]: @message', array('@human_name' => $view->storage->getHumanName(), '@view_name' => $view->storage->id(), '@message' => $e->getMessage())));
throw new DatabaseExceptionWrapper(format_string('Exception in @label[@view_name]: @message', array('@label' => $view->storage->label(), '@view_name' => $view->storage->id(), '@message' => $e->getMessage())));
}
}
......
......@@ -623,7 +623,7 @@ protected function instantiate_view($form, &$form_state) {
// Build the basic view properties and create the view.
$values = array(
'id' => $form_state['values']['id'],
'human_name' => $form_state['values']['human_name'],
'label' => $form_state['values']['label'],
'description' => $form_state['values']['description'],
'base_table' => $this->base_table,
'langcode' => language_default()->langcode,
......
......@@ -96,7 +96,7 @@ public function testLoadFunctions() {
$this->assertIdentical(array_keys($all_views), array_keys(views_get_views_as_options(TRUE)), 'Expected option keys for all views were returned.');
$expected_options = array();
foreach ($all_views as $id => $view) {
$expected_options[$id] = $view->getHumanName();
$expected_options[$id] = $view->label();
}
$this->assertIdentical($expected_options, views_get_views_as_options(TRUE), 'Expected options array was returned.');
......
......@@ -43,7 +43,7 @@ function testTokenReplacement() {
$this->executeView($view);
$expected = array(
'[view:name]' => 'Test tokens',
'[view:label]' => 'Test tokens',
'[view:description]' => 'Test view to token replacement tests.',
'[view:id]' => 'test_tokens',
'[view:title]' => 'Test token page',
......
......@@ -86,7 +86,7 @@ function testDefaultViews() {
$edit = array(
'id' => 'clone_of_glossary',
);
$this->assertTitle(t('Clone of @human_name | @site-name', array('@human_name' => 'Glossary', '@site-name' => config('system.site')->get('name'))));
$this->assertTitle(t('Clone of @label | @site-name', array('@label' => 'Glossary', '@site-name' => config('system.site')->get('name'))));
$this->drupalPost(NULL, $edit, t('Clone'));
$this->assertUrl('admin/structure/views/view/clone_of_glossary/edit', array(), 'The normal cloning name schema is applied.');
......
......@@ -42,7 +42,7 @@ public static function getInfo() {
public function randomView(array $view = array()) {
// Create a new view in the UI.
$default = array();
$default['human_name'] = $this->randomName(16);
$default['label'] = $this->randomName(16);
$default['id'] = strtolower($this->randomName(16));
$default['description'] = $this->randomName(16);
$default['page[create]'] = TRUE;
......
......@@ -26,7 +26,7 @@ public static function getInfo() {
function testOverrideDisplays() {
// Create a basic view that shows all content, with a page and a block
// display.
$view['human_name'] = $this->randomName(16);
$view['label'] = $this->randomName(16);
$view['id'] = strtolower($this->randomName(16));
$view['page[create]'] = 1;
$view['page[path]'] = $this->randomName(16);
......@@ -55,7 +55,7 @@ function testOverrideDisplays() {
// Confirm that the view block is available in the block administration UI.
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add');
$this->assertText('View: ' . $view['human_name']);
$this->assertText('View: ' . $view['label']);
// Place the block.
$this->drupalPlaceBlock("views_block:{$view['id']}-block_1");
......@@ -85,7 +85,7 @@ function testWizardMixedDefaultOverriddenDisplays() {
// identical titles, but give the block a different one, so we expect the
// page and feed to inherit their titles from the default display, but the
// block to override it.
$view['human_name'] = $this->randomName(16);
$view['label'] = $this->randomName(16);
$view['id'] = strtolower($this->randomName(16));
$view['page[create]'] = 1;
$view['page[title]'] = $this->randomName(16);
......@@ -114,7 +114,7 @@ function testWizardMixedDefaultOverriddenDisplays() {
// Confirm that the block is available in the block administration UI.
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add');
$this->assertText('View: ' . $view['human_name']);
$this->assertText('View: ' . $view['label']);
// Place the block.
$this->drupalPlaceBlock("views_block:{$view['id']}-block_1");
......@@ -167,7 +167,7 @@ function testRevertAllDisplays() {
// Create a basic view with a page, block.
// Because there is both a title on page and block we expect the title on
// the block be overriden.
$view['human_name'] = $this->randomName(16);
$view['label'] = $this->randomName(16);
$view['id'] = strtolower($this->randomName(16));
$view['page[create]'] = 1;
$view['page[title]'] = $this->randomName(16);
......
......@@ -44,7 +44,7 @@ function testEditUI() {
$this->drupalPost('admin/structure/views/settings', $edit, t('Save configuration'));
$view = array();
$view['human_name'] = $this->randomName(16);
$view['label'] = $this->randomName(16);
$view['id'] = strtolower($this->randomName(16));
$view['description'] = $this->randomName(16);
$view['page[create]'] = TRUE;
......
......@@ -37,7 +37,7 @@ public static function getInfo() {
}
/**
* Tests changing human_name, description and tag.
* Tests changing label, description and tag.
*
* @see views_ui_edit_details_form
*/
......@@ -48,7 +48,7 @@ public function testDetails() {
language_save($language);
$edit = array(
'human_name' => $this->randomName(),
'label' => $this->randomName(),
'tag' => $this->randomName(),
'description' => $this->randomName(30),
'langcode' => 'fr',
......@@ -58,7 +58,8 @@ public function testDetails() {
$this->drupalPost(NULL, array(), t('Save'));
$view = views_get_view($view_name);
foreach (array('human_name', 'tag', 'description', 'langcode') as $property) {
foreach (array('label', 'tag', 'description', 'langcode') as $property) {
$this->assertEqual($view->storage->get($property), $edit[$property], format_string('Make sure the property @property got probably saved.', array('@property' => $property)));
}
}
......
......@@ -45,7 +45,7 @@ class ViewExecutableTest extends ViewUnitTestBase {
'description',
'tag',
'base_table',
'human_name',
'label',
'core',
'display',
);
......
......@@ -33,7 +33,7 @@ class ViewStorageTest extends ViewUnitTestBase {
'description',
'tag',
'base_table',
'human_name',
'label',
'core',
'display',
);
......@@ -356,7 +356,7 @@ public function testCreateDuplicate() {
'description',
'tag',
'base_table',
'human_name',
'label',
'core',
);
......
......@@ -30,14 +30,14 @@ function testViewsWizardAndListing() {
// Create a simple and not at all useful view.
$view1 = array();
$view1['human_name'] = $this->randomName(16);
$view1['label'] = $this->randomName(16);
$view1['id'] = strtolower($this->randomName(16));
$view1['description'] = $this->randomName(16);
$view1['page[create]'] = FALSE;
$this->drupalPost('admin/structure/views/add', $view1, t('Save and edit'));
$this->assertResponse(200);
$this->drupalGet('admin/structure/views');
$this->assertText($view1['human_name']);
$this->assertText($view1['label']);
$this->assertText($view1['description']);
// @todo For now, clone is being left to config.module to solve.
foreach (array('delete', 'edit') as $operation) {
......@@ -46,7 +46,7 @@ function testViewsWizardAndListing() {
// This view should not have a block.
$this->drupalGet('admin/structure/block');