Commit a8a8b2cb authored by alexpott's avatar alexpott

Issue #2016701 by Berdir, ceng, alarcombe, daffie, rhm50: Expand TermInterface to provide methods.

parent aed35d3a
......@@ -154,7 +154,7 @@ public function testAutocompleteEdit() {
'form_id' => 'edit_field_form',
'form_token' => $token_match[1],
'form_build_id' => $build_id_match[1],
$this->field_name => implode(', ', array($this->term1->label(), 'new term', $this->term2->label())),
$this->field_name => implode(', ', array($this->term1->getName(), 'new term', $this->term2->getName())),
'op' => t('Save'),
);
......@@ -163,8 +163,8 @@ public function testAutocompleteEdit() {
$this->assertResponse(200);
$ajax_commands = drupal_json_decode($response);
$this->drupalSetContent($ajax_commands[0]['data']);
$this->assertLink($this->term1->label());
$this->assertLink($this->term2->label());
$this->assertLink($this->term1->getName());
$this->assertLink($this->term2->getName());
$this->assertText('new term');
$this->assertNoLink('new term');
......@@ -179,7 +179,7 @@ public function testAutocompleteEdit() {
// taxonomy terms, including the one that has just been newly created and
// which is not yet stored.
$this->drupalSetContent($ajax_commands[0]['data']);
$this->assertFieldByName($this->field_name, implode(', ', array($this->term1->label(), 'new term', $this->term2->label())));
$this->assertFieldByName($this->field_name, implode(', ', array($this->term1->getName(), 'new term', $this->term2->label())));
// Save the entity.
$post = array('nocssjs' => 'true');
......@@ -189,8 +189,8 @@ public function testAutocompleteEdit() {
// The full node display should now link to all entities, with the new
// one created in the database as well.
$this->drupalGet('node/' . $this->node->id());
$this->assertLink($this->term1->label());
$this->assertLink($this->term2->label());
$this->assertLink($this->term1->getName());
$this->assertLink($this->term2->getName());
$this->assertLink('new term');
}
}
......
......@@ -90,17 +90,17 @@ public function testContentEntityReferenceItem() {
$this->assertTrue($entity->field_test_taxonomy_term instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->field_test_taxonomy_term[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->field_test_taxonomy_term->target_id, $tid);
$this->assertEqual($entity->field_test_taxonomy_term->entity->name->value, $this->term->name->value);
$this->assertEqual($entity->field_test_taxonomy_term->entity->getName(), $this->term->getName());
$this->assertEqual($entity->field_test_taxonomy_term->entity->id(), $tid);
$this->assertEqual($entity->field_test_taxonomy_term->entity->uuid(), $this->term->uuid());
// Change the name of the term via the reference.
$new_name = $this->randomName();
$entity->field_test_taxonomy_term->entity->name = $new_name;
$entity->field_test_taxonomy_term->entity->setName($new_name);
$entity->field_test_taxonomy_term->entity->save();
// Verify it is the correct name.
$term = entity_load('taxonomy_term', $tid);
$this->assertEqual($term->name->value, $new_name);
$this->assertEqual($term->getName(), $new_name);
// Make sure the computed term reflects updates to the term id.
$term2 = entity_create('taxonomy_term', array(
......@@ -112,7 +112,7 @@ public function testContentEntityReferenceItem() {
$entity->field_test_taxonomy_term->target_id = $term2->id();
$this->assertEqual($entity->field_test_taxonomy_term->entity->id(), $term2->id());
$this->assertEqual($entity->field_test_taxonomy_term->entity->name->value, $term2->name->value);
$this->assertEqual($entity->field_test_taxonomy_term->entity->getName(), $term2->getName());
// Delete terms so we have nothing to reference and try again
$term->delete();
......@@ -146,8 +146,8 @@ public function testConfigEntityReferenceItem() {
$entity->field_test_taxonomy_vocabulary->entity->name = $new_name;
$entity->field_test_taxonomy_vocabulary->entity->save();
// Verify it is the correct name.
$term = entity_load('taxonomy_vocabulary', $referenced_entity_id);
$this->assertEqual($term->name, $new_name);
$vocabulary = entity_load('taxonomy_vocabulary', $referenced_entity_id);
$this->assertEqual($vocabulary->name, $new_name);
// Make sure the computed term reflects updates to the term id.
$vocabulary2 = entity_create('taxonomy_vocabulary', array(
......
......@@ -237,7 +237,7 @@ function forum_node_validate(EntityInterface $node, $form, &$form_state) {
->count()
->execute();
if ($used && !empty($term->forum_container->value)) {
form_set_error('taxonomy_forums', $form_state, t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', array('%forum' => $term->label())));
form_set_error('taxonomy_forums', $form_state, t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', array('%forum' => $term->getName())));
}
}
}
......
......@@ -145,7 +145,7 @@ protected function build($forums, TermInterface $term, $topics = array(), $paren
);
$build['#attached']['library'][] = 'forum/forum.index';
if (empty($term->forum_container->value)) {
$build['#attached']['drupal_add_feed'][] = array('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->label());
$build['#attached']['drupal_add_feed'][] = array('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->getName());
}
return $build;
......
......@@ -81,14 +81,14 @@ public function save(array $form, array &$form_state) {
switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created new @type %term.', array('%term' => $term->label(), '@type' => $this->forumFormType)));
watchdog('forum', 'Created new @type %term.', array('%term' => $term->label(), '@type' => $this->forumFormType), WATCHDOG_NOTICE, l($this->t('edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id()));
drupal_set_message($this->t('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType)));
watchdog('forum', 'Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType), WATCHDOG_NOTICE, l($this->t('edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id()));
$form_state['values']['tid'] = $term->id();
break;
case SAVED_UPDATED:
drupal_set_message($this->t('The @type %term has been updated.', array('%term' => $term->label(), '@type' => $this->forumFormType)));
watchdog('taxonomy', 'Updated @type %term.', array('%term' => $term->label(), '@type' => $this->forumFormType), WATCHDOG_NOTICE, l($this->t('edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id()));
drupal_set_message($this->t('The @type %term has been updated.', array('%term' => $term->getName(), '@type' => $this->forumFormType)));
watchdog('taxonomy', 'Updated @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType), WATCHDOG_NOTICE, l($this->t('edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id()));
// Clear the page and block caches to avoid stale data.
Cache::invalidateTags(array('content' => TRUE));
break;
......@@ -149,7 +149,7 @@ protected function forumParentSelect($tid, $title) {
if ($tree) {
foreach ($tree as $term) {
if (!in_array($term->id(), $exclude)) {
$options[$term->id()] = str_repeat(' -- ', $term->depth) . $term->label();
$options[$term->id()] = str_repeat(' -- ', $term->depth) . $term->getName();
}
}
}
......
......@@ -118,7 +118,7 @@ function testPagePreview() {
$edit = array();
$edit[$title_key] = $this->randomName(8);
$edit[$body_key] = $this->randomName(16);
$edit[$term_key] = $this->term->label();
$edit[$term_key] = $this->term->getName();
$this->drupalPostForm('node/add/page', $edit, t('Preview'));
// Check that the preview is displaying the title, body and term.
......@@ -150,12 +150,12 @@ function testPagePreview() {
$edit = array();
$newterm1 = $this->randomName(8);
$newterm2 = $this->randomName(8);
$edit[$term_key] = $this->term->label() . ', ' . $newterm1 . ', ' . $newterm2;
$edit[$term_key] = $this->term->getName() . ', ' . $newterm1 . ', ' . $newterm2;
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Preview'));
$this->assertRaw('>' . $newterm1 . '<', 'First new term displayed.');
$this->assertRaw('>' . $newterm2 . '<', 'Second new term displayed.');
// The first term should be displayed as link, the others not.
$this->assertLink($this->term->label());
$this->assertLink($this->term->getName());
$this->assertNoLink($newterm1);
$this->assertNoLink($newterm2);
......@@ -170,7 +170,7 @@ function testPagePreview() {
$this->assertRaw('>' . $newterm1 . '<', 'First existing term displayed.');
$this->assertRaw('>' . $newterm2 . '<', 'Second existing term displayed.');
$this->assertRaw('>' . $newterm3 . '<', 'Third new term displayed.');
$this->assertNoText($this->term->label());
$this->assertNoText($this->term->getName());
$this->assertLink($newterm1);
$this->assertLink($newterm2);
$this->assertNoLink($newterm3);
......
......@@ -103,7 +103,7 @@ public function setUp() {
* Tests the plain formatter.
*/
public function testPlainFormatter() {
$this->assertFormatterRdfa('taxonomy_term_reference_plain', 'http://schema.org/about', $this->term->label(), 'literal');
$this->assertFormatterRdfa('taxonomy_term_reference_plain', 'http://schema.org/about', $this->term->getName(), 'literal');
}
/**
......
......@@ -327,7 +327,7 @@ protected function doTermRdfaTests() {
// Term name.
$expected_value = array(
'type' => 'literal',
'value' => $this->term->get('name')->value,
'value' => $this->term->getName(),
'lang' => 'en',
);
$this->assertTrue($graph->hasProperty($this->termUri, 'http://schema.org/name', $expected_value), "Term name was found (schema:name) on term page.");
......@@ -414,7 +414,7 @@ protected function assertRdfaArticleProperties($graph, $message_prefix) {
// Tag name.
$expected_value = array(
'type' => 'literal',
'value' => $this->term->get('name')->value,
'value' => $this->term->getName(),
'lang' => 'en',
);
// @todo enable with https://drupal.org/node/2072791
......
......@@ -66,14 +66,14 @@ function testTaxonomyTermRdfaAttributes() {
// Term label.
$expected_value = array(
'type' => 'literal',
'value' => $term->label(),
'value' => $term->getName(),
'lang' => 'en',
);
$this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Term label found in RDF output (rdfs:label).');
// Term label.
$expected_value = array(
'type' => 'literal',
'value' => $term->label(),
'value' => $term->getName(),
'lang' => 'en',
);
$this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/2004/02/skos/core#prefLabel', $expected_value), 'Term label found in RDF output (skos:prefLabel).');
......
......@@ -128,7 +128,7 @@ function testNodeTeaser() {
//$this->assertTrue($graph->hasProperty($taxonomy_term_1_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Taxonomy term type found in RDF output (skos:Concept).');
$expected_value = array(
'type' => 'literal',
'value' => $term1->label(),
'value' => $term1->getName(),
);
//$this->assertTrue($graph->hasProperty($taxonomy_term_1_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Taxonomy term name found in RDF output (rdfs:label).');
// Term 2.
......@@ -139,7 +139,7 @@ function testNodeTeaser() {
//$this->assertTrue($graph->hasProperty($taxonomy_term_2_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Taxonomy term type found in RDF output (skos:Concept).');
$expected_value = array(
'type' => 'literal',
'value' => $term2->label(),
'value' => $term2->getName(),
);
//$this->assertTrue($graph->hasProperty($taxonomy_term_2_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Taxonomy term name found in RDF output (rdfs:label).');
}
......
......@@ -536,7 +536,7 @@ function rdf_preprocess_taxonomy_term(&$variables) {
'about' => url('taxonomy/term/' . $term->id()),
'typeof' => $bundle_mapping['types'],
'property' => $name_field_mapping['properties'],
'content' => $term->label(),
'content' => $term->getName(),
),
);
drupal_add_html_head($term_label_meta, 'rdf_term_label');
......
......@@ -385,7 +385,7 @@ public function testTaxonomyTermHooks() {
));
$_SESSION['entity_crud_hook_test'] = array();
$term->name = 'New name';
$term->setName('New name');
$term->save();
$this->assertHookMessageOrder(array(
......
......@@ -270,7 +270,7 @@ function testBreadCrumbs() {
$tree += array(
$link['link_path'] => $link['link_title'],
);
$this->assertBreadcrumb($link['link_path'], $trail, $term->label(), $tree);
$this->assertBreadcrumb($link['link_path'], $trail, $term->getName(), $tree);
$this->assertRaw(check_plain($parent->getTitle()), 'Tagged node found.');
// Additionally make sure that this link appears only once; i.e., the
......@@ -286,7 +286,7 @@ function testBreadCrumbs() {
// Next iteration should expect this tag as parent link.
// Note: Term name, not link name, due to taxonomy_term_page().
$trail += array(
$link['link_path'] => $term->label(),
$link['link_path'] => $term->getName(),
);
}
......
......@@ -67,7 +67,7 @@ public function vocabularyTitle(VocabularyInterface $taxonomy_vocabulary) {
* The term label.
*/
public function termTitle(TermInterface $taxonomy_term) {
return Xss::filter($taxonomy_term->label());
return Xss::filter($taxonomy_term->getName());
}
/**
......
......@@ -196,8 +196,8 @@ protected function getMatchingTerms($tags_typed, array $vids, $tag_last) {
$terms = $this->termStorage->loadMultiple(array_keys($tids));
foreach ($terms as $term) {
// Term names containing commas or quotes must be wrapped in quotes.
$name = Tags::encode($term->label());
$matches[] = array('value' => $prefix . $name, 'label' => String::checkPlain($term->label()));
$name = Tags::encode($term->getName());
$matches[] = array('value' => $prefix . $name, 'label' => String::checkPlain($term->getName()));
}
return $matches;
}
......
......@@ -55,93 +55,12 @@
class Term extends ContentEntityBase implements TermInterface {
/**
* The taxonomy term ID.
*
* @var \Drupal\Core\Field\FieldItemListInterface
*/
public $tid;
/**
* The term UUID.
*
* @var \Drupal\Core\Field\FieldItemListInterface
*/
public $uuid;
/**
* The taxonomy vocabulary ID this term belongs to.
*
* @var \Drupal\Core\Field\FieldItemListInterface
*/
public $vid;
/**
* Name of the term.
*
* @var \Drupal\Core\Field\FieldItemListInterface
*/
public $name;
/**
* Description of the term.
*
* @var \Drupal\Core\Field\FieldItemListInterface
*/
public $description;
/**
* The text format name for the term's description.
*
* @var \Drupal\Core\Field\FieldItemListInterface
*/
public $format;
/**
* The weight of this term.
*
* This property stores the weight of this term in relation to other terms of
* the same vocabulary.
*
* @var \Drupal\Core\Field\FieldItemListInterface
*/
public $weight;
/**
* The parent term(s) for this term.
*
* This property is not loaded, but may be used to modify the term parents via
* Term::save().
*
* The property can be set to an array of term IDs. An entry of 0 means this
* term does not have any parents. When omitting this variable during an
* update, the existing hierarchy for the term remains unchanged.
*
* @var \Drupal\Core\Field\FieldItemListInterface
*/
public $parent;
/**
* Implements Drupal\Core\Entity\EntityInterface::id().
* {@inheritdoc}
*/
public function id() {
return $this->get('tid')->value;
}
/**
* {@inheritdoc}
*/
protected function init() {
parent::init();
unset($this->tid);
unset($this->uuid);
unset($this->vid);
unset($this->name);
unset($this->weight);
unset($this->format);
unset($this->description);
unset($this->parent);
}
/**
* {@inheritdoc}
*/
......@@ -244,7 +163,74 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
* {@inheritdoc}
*/
public function getChangedTime() {
return $this->changed->value;
return $this->get('changed')->value;
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->get('description')->value;
}
/**
* {@inheritdoc}
*/
public function setDescription($description) {
$this->set('description', $description);
return $this;
}
/**
* {@inheritdoc}
*/
public function getFormat() {
return $this->get('description')->format;
}
/**
* {@inheritdoc}
*/
public function setFormat($format) {
$this->get('description')->format = $format;
return $this;
}
/**
* {@inheritdoc}
*/
public function getName() {
return $this->label();
}
/**
* {@inheritdoc}
*/
public function setName($name) {
$this->set('name', $name);
return $this;
}
/**
* {@inheritdoc}
*/
public function getWeight() {
return $this->get('weight')->value;
}
/**
* {@inheritdoc}
*/
public function setWeight($weight) {
$this->set('weight', $weight);
return $this;
}
/**
* {@inheritdoc}
*/
public function getVocabularyId() {
return $this->get('vid')->target_id;
}
}
......@@ -212,7 +212,7 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $
$form['terms'][$key]['term'] = array(
'#prefix' => !empty($indentation) ? drupal_render($indentation) : '',
'#type' => 'link',
'#title' => $term->label(),
'#title' => $term->getName(),
'#route_name' => $uri['route_name'],
'#route_parameters' => $uri['route_parameters'],
);
......@@ -249,7 +249,7 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $
'#delta' => $delta,
'#title' => $this->t('Weight for added term'),
'#title_display' => 'invisible',
'#default_value' => $term->weight->value,
'#default_value' => $term->getWeight(),
'#attributes' => array(
'class' => array('term-weight'),
),
......@@ -387,8 +387,8 @@ public function submitForm(array &$form, array &$form_state) {
$weight = 0;
$term = $tree[0];
while ($term->id() != $form['#first_tid']) {
if ($term->parents[0] == 0 && $term->weight->value != $weight) {
$term->weight->value = $weight;
if ($term->parents[0] == 0 && $term->getWeight() != $weight) {
$term->setWeight($weight);
$changed_terms[$term->id()] = $term;
}
$weight++;
......@@ -402,15 +402,15 @@ public function submitForm(array &$form, array &$form_state) {
if (isset($form['terms'][$tid]['#term'])) {
$term = $form['terms'][$tid]['#term'];
// Give terms at the root level a weight in sequence with terms on previous pages.
if ($values['term']['parent'] == 0 && $term->weight->value != $weight) {
$term->weight->value = $weight;
if ($values['term']['parent'] == 0 && $term->getWeight() != $weight) {
$term->setWeight($weight);
$changed_terms[$term->id()] = $term;
}
// Terms not at the root level can safely start from 0 because they're all on this page.
elseif ($values['term']['parent'] > 0) {
$level_weights[$values['term']['parent']] = isset($level_weights[$values['term']['parent']]) ? $level_weights[$values['term']['parent']] + 1 : 0;
if ($level_weights[$values['term']['parent']] != $term->weight->value) {
$term->weight->value = $level_weights[$values['term']['parent']];
if ($level_weights[$values['term']['parent']] != $term->getWeight()) {
$term->setWeight($level_weights[$values['term']['parent']]);
$changed_terms[$term->id()] = $term;
}
}
......@@ -427,9 +427,9 @@ public function submitForm(array &$form, array &$form_state) {
// Build a list of all terms that need to be updated on following pages.
for ($weight; $weight < count($tree); $weight++) {
$term = $tree[$weight];
if ($term->parents[0] == 0 && $term->weight->value != $weight) {
if ($term->parents[0] == 0 && $term->getWeight() != $weight) {
$term->parent->value = $term->parents[0];
$term->weight->value = $weight;
$term->setWeight($weight);
$changed_terms[$term->id()] = $term;
}
$hierarchy = $term->parents[0] != 0 ? TAXONOMY_HIERARCHY_SINGLE : $hierarchy;
......
......@@ -28,7 +28,7 @@ public function getFormId() {
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete the term %title?', array('%title' => $this->entity->label()));
return $this->t('Are you sure you want to delete the term %title?', array('%title' => $this->entity->getName()));
}
/**
......@@ -65,8 +65,8 @@ public function submit(array $form, array &$form_state) {
// @todo Move to storage controller http://drupal.org/node/1988712
taxonomy_check_vocabulary_hierarchy($vocabulary, array('tid' => $this->entity->id()));
drupal_set_message($this->t('Deleted term %name.', array('%name' => $this->entity->label())));
watchdog('taxonomy', 'Deleted term %name.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE);
drupal_set_message($this->t('Deleted term %name.', array('%name' => $this->entity->getName())));
watchdog('taxonomy', 'Deleted term %name.', array('%name' => $this->entity->getName()), WATCHDOG_NOTICE);
$form_state['redirect_route']['route_name'] = 'taxonomy.vocabulary_list';
Cache::invalidateTags(array('content' => TRUE));
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Component\Utility\String;
/**
* Plugin implementation of the 'taxonomy_term_reference_link' formatter.
......@@ -27,13 +28,12 @@ class LinkFormatter extends TaxonomyFormatterBase {
*/
public function viewElements(FieldItemListInterface $items) {
$elements = array();
// Terms without target_id do not exist yet, theme such terms as just their
// name.
foreach ($items as $delta => $item) {
if (!$item->target_id) {
$elements[$delta] = array(
'#markup' => check_plain($item->entity->label()),
'#markup' => String::checkPlain($item->entity->label()),
);
}
else {
......@@ -42,7 +42,7 @@ public function viewElements(FieldItemListInterface $items) {
$uri = $term->urlInfo();
$elements[$delta] = array(
'#type' => 'link',
'#title' => $term->label(),
'#title' => $term->getName(),
'#route_name' => $uri['route_name'],
'#route_parameters' => $uri['route_parameters'],
'#options' => $uri['options'],
......
......@@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Component\Utility\String;
/**
* Plugin implementation of the 'taxonomy_term_reference_plain' formatter.
......@@ -30,7 +31,7 @@ public function viewElements(FieldItemListInterface $items) {
foreach ($items as $delta => $item) {
$elements[$delta] = array(
'#markup' => check_plain($item->entity->label()),
'#markup' => String::checkPlain($item->entity->label()),
);
}
......
......@@ -77,7 +77,7 @@ public function getSettableOptions(AccountInterface $account = NULL) {
if ($vocabulary = entity_load('taxonomy_vocabulary', $tree['vocabulary'])) {
if ($terms = taxonomy_get_tree($vocabulary->id(), $tree['parent'], NULL, TRUE)) {
foreach ($terms as $term) {
$options[$term->id()] = str_repeat('-', $term->depth) . $term->label();
$options[$term->id()] = str_repeat('-', $term->depth) . $term->getName();
}
}
}
......
......@@ -66,7 +66,7 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTA
if ($vocabulary = entity_load('taxonomy_vocabulary', $bundle)) {
if ($terms = taxonomy_get_tree($vocabulary->id(), 0, NULL, TRUE)) {
foreach ($terms as $term) {
$options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . String::checkPlain($term->label());
$options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . String::checkPlain($term->getName());
}
}
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\argument;
use Drupal\views\Plugin\views\argument\ManyToOne;
use Drupal\Component\Utility\String;
/**
* Allow taxonomy term ID(s) as argument.
......@@ -24,8 +25,8 @@ public function titleQuery() {
->fields('td', array('name'))
->condition('td.tid', $this->value)
->execute();
foreach ($result as $term) {
$titles[] = check_plain($term->name);
foreach ($result as $term_record) {
$titles[] = String::checkPlain($term_record->name);
}
return $titles;
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\argument;
use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
use Drupal\Component\Utility\String;
/**
* Argument handler for taxonomy terms with depth.
......@@ -121,7 +122,7 @@ public function query($group_by = FALSE) {
function title() {
$term = entity_load('taxonomy_term', $this->argument);
if (!empty($term)) {
return check_plain($term->label());
return String::checkPlain($term->getName());
}
// TODO review text
return t('No name');
......
......@@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\argument;
use Drupal\views\Plugin\views\argument\Numeric;
use Drupal\Component\Utility\String;
/**
* Argument handler for basic taxonomy tid.
......@@ -26,7 +27,7 @@ function title() {
if ($this->argument) {
$term = entity_load('taxonomy_term', $this->argument);
if (!empty($term)) {
return check_plain($term->label());
return String::checkPlain($term->getName());
}
}
// TODO review text
......