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