Commit 0a91fd93 authored by Dries's avatar Dries

Issue #2020405 by Pancho: Correct misspelling of 'referenceable'.

parent 0cbc8d34
......@@ -115,7 +115,7 @@ function entity_reference_field_validate(EntityInterface $entity = NULL, $field,
}
if ($ids) {
$valid_ids = entity_reference_get_selection_handler($instance, $entity)->validateReferencableEntities(array_keys($ids));
$valid_ids = entity_reference_get_selection_handler($instance, $entity)->validateReferenceableEntities(array_keys($ids));
$invalid_entities = array_diff_key($ids, array_flip($valid_ids));
if ($invalid_entities) {
......@@ -353,7 +353,7 @@ function entity_reference_settings_ajax_submit($form, &$form_state) {
* Implements hook_options_list().
*/
function entity_reference_options_list(FieldDefinitionInterface $field_definition, EntityInterface $entity) {
if (!$options = entity_reference_get_selection_handler($field_definition, $entity)->getReferencableEntities()) {
if (!$options = entity_reference_get_selection_handler($field_definition, $entity)->getReferenceableEntities()) {
return array();
}
......
......@@ -77,7 +77,7 @@ public function getMatches($field, $instance, $entity_type, $entity_id = '', $pr
// Get an array of matching entities.
$widget = entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')->getComponent($instance['field_name']);
$match_operator = !empty($widget['settings']['match_operator']) ? $widget['settings']['match_operator'] : 'CONTAINS';
$entity_labels = $handler->getReferencableEntities($string, $match_operator, 10);
$entity_labels = $handler->getReferenceableEntities($string, $match_operator, 10);
// Loop through the entities and convert them into autocomplete output.
foreach ($entity_labels as $values) {
......
......@@ -25,23 +25,23 @@ public static function settingsForm(&$field, &$instance) {
}
/**
* Implements SelectionInterface::getReferencableEntities().
* Implements SelectionInterface::getReferenceableEntities().
*/
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
return array();
}
/**
* Implements SelectionInterface::countReferencableEntities().
* Implements SelectionInterface::countReferenceableEntities().
*/
public function countReferencableEntities($match = NULL, $match_operator = 'CONTAINS') {
public function countReferenceableEntities($match = NULL, $match_operator = 'CONTAINS') {
return 0;
}
/**
* Implements SelectionInterface::validateReferencableEntities().
* Implements SelectionInterface::validateReferenceableEntities().
*/
public function validateReferencableEntities(array $ids) {
public function validateReferenceableEntities(array $ids) {
return array();
}
......
......@@ -20,21 +20,21 @@
interface SelectionInterface {
/**
* Returns a list of referencable entities.
* Returns a list of referenceable entities.
*
* @return array
* An array of referencable entities. Keys are entity IDs and
* An array of referenceable entities. Keys are entity IDs and
* values are (safe HTML) labels to be displayed to the user.
*/
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0);
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0);
/**
* Counts entities that are referencable by a given field.
* Counts entities that are referenceable by a given field.
*
* @return int
* The number of referencable entities.
* The number of referenceable entities.
*/
public function countReferencableEntities($match = NULL, $match_operator = 'CONTAINS');
public function countReferenceableEntities($match = NULL, $match_operator = 'CONTAINS');
/**
* Validates that entities can be referenced by this field.
......@@ -42,7 +42,7 @@ public function countReferencableEntities($match = NULL, $match_operator = 'CONT
* @return array
* An array of valid entity IDs.
*/
public function validateReferencableEntities(array $ids);
public function validateReferenceableEntities(array $ids);
/**
* Validates input from an autocomplete widget that has no ID.
......
......@@ -155,9 +155,9 @@ public static function settingsForm(&$field, &$instance) {
}
/**
* Implements SelectionInterface::getReferencableEntities().
* Implements SelectionInterface::getReferenceableEntities().
*/
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
$target_type = $this->fieldDefinition->getFieldSetting('target_type');
$query = $this->buildEntityQuery($match, $match_operator);
......@@ -182,9 +182,9 @@ public function getReferencableEntities($match = NULL, $match_operator = 'CONTAI
}
/**
* Implements SelectionInterface::countReferencableEntities().
* Implements SelectionInterface::countReferenceableEntities().
*/
public function countReferencableEntities($match = NULL, $match_operator = 'CONTAINS') {
public function countReferenceableEntities($match = NULL, $match_operator = 'CONTAINS') {
$query = $this->buildEntityQuery($match, $match_operator);
return $query
->count()
......@@ -192,9 +192,9 @@ public function countReferencableEntities($match = NULL, $match_operator = 'CONT
}
/**
* Implements SelectionInterface::validateReferencableEntities().
* Implements SelectionInterface::validateReferenceableEntities().
*/
public function validateReferencableEntities(array $ids) {
public function validateReferenceableEntities(array $ids) {
$result = array();
if ($ids) {
$target_type = $this->fieldDefinition->getFieldSetting('target_type');
......@@ -212,7 +212,7 @@ public function validateReferencableEntities(array $ids) {
* Implements SelectionInterface::validateAutocompleteInput().
*/
public function validateAutocompleteInput($input, &$element, &$form_state, $form, $strict = TRUE) {
$entities = $this->getReferencableEntities($input, '=', 6);
$entities = $this->getReferenceableEntities($input, '=', 6);
$params = array(
'%value' => $input,
'@value' => $input,
......@@ -244,7 +244,7 @@ public function validateAutocompleteInput($input, &$element, &$form_state, $form
}
/**
* Builds an EntityQuery to get referencable entities.
* Builds an EntityQuery to get referenceable entities.
*
* @param string|null $match
* (Optional) Text to match the label against. Defaults to NULL.
......
......@@ -33,15 +33,15 @@ function setUp() {
$this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
}
protected function assertReferencable(FieldDefinitionInterface $field_definition, $tests, $handler_name) {
protected function assertReferenceable(FieldDefinitionInterface $field_definition, $tests, $handler_name) {
$handler = entity_reference_get_selection_handler($field_definition);
foreach ($tests as $test) {
foreach ($test['arguments'] as $arguments) {
$result = call_user_func_array(array($handler, 'getReferencableEntities'), $arguments);
$result = call_user_func_array(array($handler, 'getReferenceableEntities'), $arguments);
$this->assertEqual($result, $test['result'], format_string('Valid result set returned by @handler.', array('@handler' => $handler_name)));
$result = call_user_func_array(array($handler, 'countReferencableEntities'), $arguments);
$result = call_user_func_array(array($handler, 'countReferenceableEntities'), $arguments);
if (!empty($test['result'])) {
$bundle = key($test['result']);
$count = count($test['result'][$bundle]);
......@@ -119,7 +119,7 @@ public function testNodeHandler() {
// Test as a non-admin.
$normal_user = $this->drupalCreateUser(array('access content'));
$GLOBALS['user'] = $normal_user;
$referencable_tests = array(
$referenceable_tests = array(
array(
'arguments' => array(
array(NULL, 'CONTAINS'),
......@@ -166,12 +166,12 @@ public function testNodeHandler() {
'result' => array(),
),
);
$this->assertReferencable($instance, $referencable_tests, 'Node handler');
$this->assertReferenceable($instance, $referenceable_tests, 'Node handler');
// Test as an admin.
$admin_user = $this->drupalCreateUser(array('access content', 'bypass node access'));
$GLOBALS['user'] = $admin_user;
$referencable_tests = array(
$referenceable_tests = array(
array(
'arguments' => array(
array(NULL, 'CONTAINS'),
......@@ -195,7 +195,7 @@ public function testNodeHandler() {
),
),
);
$this->assertReferencable($instance, $referencable_tests, 'Node handler (admin)');
$this->assertReferenceable($instance, $referenceable_tests, 'Node handler (admin)');
}
/**
......@@ -265,7 +265,7 @@ public function testUserHandler() {
// Test as a non-admin.
$GLOBALS['user'] = $users['non_admin'];
$referencable_tests = array(
$referenceable_tests = array(
array(
'arguments' => array(
array(NULL, 'CONTAINS'),
......@@ -301,10 +301,10 @@ public function testUserHandler() {
'result' => array(),
),
);
$this->assertReferencable($instance, $referencable_tests, 'User handler');
$this->assertReferenceable($instance, $referenceable_tests, 'User handler');
$GLOBALS['user'] = $users['admin'];
$referencable_tests = array(
$referenceable_tests = array(
array(
'arguments' => array(
array(NULL, 'CONTAINS'),
......@@ -340,7 +340,7 @@ public function testUserHandler() {
),
),
);
$this->assertReferencable($instance, $referencable_tests, 'User handler (admin)');
$this->assertReferenceable($instance, $referenceable_tests, 'User handler (admin)');
}
/**
......@@ -436,7 +436,7 @@ public function testCommentHandler() {
// Test as a non-admin.
$normal_user = $this->drupalCreateUser(array('access content', 'access comments'));
$GLOBALS['user'] = $normal_user;
$referencable_tests = array(
$referenceable_tests = array(
array(
'arguments' => array(
array(NULL, 'CONTAINS'),
......@@ -470,12 +470,12 @@ public function testCommentHandler() {
'result' => array(),
),
);
$this->assertReferencable($instance, $referencable_tests, 'Comment handler');
$this->assertReferenceable($instance, $referenceable_tests, 'Comment handler');
// Test as a comment admin.
$admin_user = $this->drupalCreateUser(array('access content', 'access comments', 'administer comments'));
$GLOBALS['user'] = $admin_user;
$referencable_tests = array(
$referenceable_tests = array(
array(
'arguments' => array(
array(NULL, 'CONTAINS'),
......@@ -488,12 +488,12 @@ public function testCommentHandler() {
),
),
);
$this->assertReferencable($instance, $referencable_tests, 'Comment handler (comment admin)');
$this->assertReferenceable($instance, $referenceable_tests, 'Comment handler (comment admin)');
// Test as a node and comment admin.
$admin_user = $this->drupalCreateUser(array('access content', 'access comments', 'administer comments', 'bypass node access'));
$GLOBALS['user'] = $admin_user;
$referencable_tests = array(
$referenceable_tests = array(
array(
'arguments' => array(
array(NULL, 'CONTAINS'),
......@@ -507,6 +507,6 @@ public function testCommentHandler() {
),
),
);
$this->assertReferencable($instance, $referencable_tests, 'Comment handler (comment + node admin)');
$this->assertReferenceable($instance, $referenceable_tests, 'Comment handler (comment + node admin)');
}
}
......@@ -125,7 +125,7 @@ public function testSort() {
// Not only assert the result, but make sure the keys are sorted as
// expected.
$result = $handler->getReferencableEntities();
$result = $handler->getReferenceableEntities();
$expected_result = array(
$nodes['published2']->nid => $node_labels['published2'],
$nodes['published1']->nid => $node_labels['published1'],
......@@ -138,7 +138,7 @@ public function testSort() {
'direction' => 'ASC',
);
$handler = entity_reference_get_selection_handler($instance);
$result = $handler->getReferencableEntities();
$result = $handler->getReferenceableEntities();
$expected_result = array(
$nodes['published1']->nid => $node_labels['published1'],
$nodes['published2']->nid => $node_labels['published2'],
......
......@@ -71,7 +71,7 @@ public function testSelectionHandler() {
// Get values from selection handler.
$handler = entity_reference_get_selection_handler($instance);
$result = $handler->getReferencableEntities();
$result = $handler->getReferenceableEntities();
$success = FALSE;
foreach ($result as $node_type => $values) {
......
......@@ -51,11 +51,11 @@ public static function settingsForm(&$field, &$instance) {
/**
* Overrides SelectionBase::getReferencableEntities().
* Overrides SelectionBase::getReferenceableEntities().
*/
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
if ($match || $limit) {
return parent::getReferencableEntities($match , $match_operator, $limit);
return parent::getReferenceableEntities($match , $match_operator, $limit);
}
$options = array();
......
......@@ -155,9 +155,9 @@ protected function initializeView($match = NULL, $match_operator = 'CONTAINS', $
}
/**
* Implements \Drupal\entity_reference\Plugin\Type\Selection\SelectionInterface::getReferencableEntities().
* Implements \Drupal\entity_reference\Plugin\Type\Selection\SelectionInterface::getReferenceableEntities().
*/
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
$handler_settings = $this->fieldDefinition->getFieldSetting('handler_settings');
$display_name = $handler_settings['view']['display_name'];
$arguments = $handler_settings['view']['arguments'];
......@@ -178,17 +178,17 @@ public function getReferencableEntities($match = NULL, $match_operator = 'CONTAI
}
/**
* Implements \Drupal\entity_reference\Plugin\Type\Selection\SelectionInterface::countReferencableEntities().
* Implements \Drupal\entity_reference\Plugin\Type\Selection\SelectionInterface::countReferenceableEntities().
*/
public function countReferencableEntities($match = NULL, $match_operator = 'CONTAINS') {
$this->getReferencableEntities($match, $match_operator);
public function countReferenceableEntities($match = NULL, $match_operator = 'CONTAINS') {
$this->getReferenceableEntities($match, $match_operator);
return $this->view->pager->getTotalItems();
}
/**
* Implements \Drupal\entity_reference\Plugin\Type\Selection\SelectionInterface::validateReferencableEntities().
* Implements \Drupal\entity_reference\Plugin\Type\Selection\SelectionInterface::validateReferenceableEntities().
*/
public function validateReferencableEntities(array $ids) {
public function validateReferenceableEntities(array $ids) {
$handler_settings = $this->fieldDefinition->getFieldSetting('handler_settings');
$display_name = $handler_settings['view']['display_name'];
$arguments = $handler_settings['view']['arguments'];
......
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