Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
0a91fd93
Commit
0a91fd93
authored
Jun 29, 2013
by
Dries Buytaert
Browse files
Issue
#2020405
by Pancho: Correct misspelling of 'referenceable'.
parent
0cbc8d34
Changes
10
Hide whitespace changes
Inline
Side-by-side
core/modules/entity_reference/entity_reference.module
View file @
0a91fd93
...
...
@@ -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
)
->
validateReferenc
e
ableEntities
(
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
)
->
getReferenc
e
ableEntities
())
{
return
array
();
}
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php
View file @
0a91fd93
...
...
@@ -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
->
getReferenc
e
ableEntities
(
$string
,
$match_operator
,
10
);
// Loop through the entities and convert them into autocomplete output.
foreach
(
$entity_labels
as
$values
)
{
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/Selection/SelectionBroken.php
View file @
0a91fd93
...
...
@@ -25,23 +25,23 @@ public static function settingsForm(&$field, &$instance) {
}
/**
* Implements SelectionInterface::getReferencableEntities().
* Implements SelectionInterface::getReferenc
e
ableEntities().
*/
public
function
getReferencableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
,
$limit
=
0
)
{
public
function
getReferenc
e
ableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
,
$limit
=
0
)
{
return
array
();
}
/**
* Implements SelectionInterface::countReferencableEntities().
* Implements SelectionInterface::countReferenc
e
ableEntities().
*/
public
function
countReferencableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
)
{
public
function
countReferenc
e
ableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
)
{
return
0
;
}
/**
* Implements SelectionInterface::validateReferencableEntities().
* Implements SelectionInterface::validateReferenc
e
ableEntities().
*/
public
function
validateReferencableEntities
(
array
$ids
)
{
public
function
validateReferenc
e
ableEntities
(
array
$ids
)
{
return
array
();
}
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/Selection/SelectionInterface.php
View file @
0a91fd93
...
...
@@ -20,21 +20,21 @@
interface
SelectionInterface
{
/**
* Returns a list of referencable entities.
* Returns a list of referenc
e
able entities.
*
* @return array
* An array of referencable entities. Keys are entity IDs and
* An array of referenc
e
able 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
getReferenc
e
ableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
,
$limit
=
0
);
/**
* Counts entities that are referencable by a given field.
* Counts entities that are referenc
e
able by a given field.
*
* @return int
* The number of referencable entities.
* The number of referenc
e
able entities.
*/
public
function
countReferencableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
);
public
function
countReferenc
e
ableEntities
(
$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
validateReferenc
e
ableEntities
(
array
$ids
);
/**
* Validates input from an autocomplete widget that has no ID.
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php
View file @
0a91fd93
...
...
@@ -155,9 +155,9 @@ public static function settingsForm(&$field, &$instance) {
}
/**
* Implements SelectionInterface::getReferencableEntities().
* Implements SelectionInterface::getReferenc
e
ableEntities().
*/
public
function
getReferencableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
,
$limit
=
0
)
{
public
function
getReferenc
e
ableEntities
(
$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::countReferenc
e
ableEntities().
*/
public
function
countReferencableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
)
{
public
function
countReferenc
e
ableEntities
(
$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::validateReferenc
e
ableEntities().
*/
public
function
validateReferencableEntities
(
array
$ids
)
{
public
function
validateReferenc
e
ableEntities
(
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
->
getReferenc
e
ableEntities
(
$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 referenc
e
able entities.
*
* @param string|null $match
* (Optional) Text to match the label against. Defaults to NULL.
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php
View file @
0a91fd93
...
...
@@ -33,15 +33,15 @@ function setUp() {
$this
->
drupalCreateContentType
(
array
(
'type'
=>
'article'
,
'name'
=>
'Article'
));
}
protected
function
assertReferencable
(
FieldDefinitionInterface
$field_definition
,
$tests
,
$handler_name
)
{
protected
function
assertReferenc
e
able
(
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
,
'getReferenc
e
ableEntities'
),
$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
,
'countReferenc
e
ableEntities'
),
$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
(
$referenc
e
able_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
->
assertReferenc
e
able
(
$instance
,
$referenc
e
able_tests
,
'Node handler'
);
// Test as an admin.
$admin_user
=
$this
->
drupalCreateUser
(
array
(
'access content'
,
'bypass node access'
));
$GLOBALS
[
'user'
]
=
$admin_user
;
$referencable_tests
=
array
(
$referenc
e
able_tests
=
array
(
array
(
'arguments'
=>
array
(
array
(
NULL
,
'CONTAINS'
),
...
...
@@ -195,7 +195,7 @@ public function testNodeHandler() {
),
),
);
$this
->
assertReferencable
(
$instance
,
$referencable_tests
,
'Node handler (admin)'
);
$this
->
assertReferenc
e
able
(
$instance
,
$referenc
e
able_tests
,
'Node handler (admin)'
);
}
/**
...
...
@@ -265,7 +265,7 @@ public function testUserHandler() {
// Test as a non-admin.
$GLOBALS
[
'user'
]
=
$users
[
'non_admin'
];
$referencable_tests
=
array
(
$referenc
e
able_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
->
assertReferenc
e
able
(
$instance
,
$referenc
e
able_tests
,
'User handler'
);
$GLOBALS
[
'user'
]
=
$users
[
'admin'
];
$referencable_tests
=
array
(
$referenc
e
able_tests
=
array
(
array
(
'arguments'
=>
array
(
array
(
NULL
,
'CONTAINS'
),
...
...
@@ -340,7 +340,7 @@ public function testUserHandler() {
),
),
);
$this
->
assertReferencable
(
$instance
,
$referencable_tests
,
'User handler (admin)'
);
$this
->
assertReferenc
e
able
(
$instance
,
$referenc
e
able_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
(
$referenc
e
able_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
->
assertReferenc
e
able
(
$instance
,
$referenc
e
able_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
(
$referenc
e
able_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
->
assertReferenc
e
able
(
$instance
,
$referenc
e
able_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
(
$referenc
e
able_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
->
assertReferenc
e
able
(
$instance
,
$referenc
e
able_tests
,
'Comment handler (comment + node admin)'
);
}
}
core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php
View file @
0a91fd93
...
...
@@ -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
->
getReferenc
e
ableEntities
();
$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
->
getReferenc
e
ableEntities
();
$expected_result
=
array
(
$nodes
[
'published1'
]
->
nid
=>
$node_labels
[
'published1'
],
$nodes
[
'published2'
]
->
nid
=>
$node_labels
[
'published2'
],
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/Tests/Views/SelectionTest.php
View file @
0a91fd93
...
...
@@ -71,7 +71,7 @@ public function testSelectionHandler() {
// Get values from selection handler.
$handler
=
entity_reference_get_selection_handler
(
$instance
);
$result
=
$handler
->
getReferencableEntities
();
$result
=
$handler
->
getReferenc
e
ableEntities
();
$success
=
FALSE
;
foreach
(
$result
as
$node_type
=>
$values
)
{
...
...
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php
View file @
0a91fd93
...
...
@@ -51,11 +51,11 @@ public static function settingsForm(&$field, &$instance) {
/**
* Overrides SelectionBase::getReferencableEntities().
* Overrides SelectionBase::getReferenc
e
ableEntities().
*/
public
function
getReferencableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
,
$limit
=
0
)
{
public
function
getReferenc
e
ableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
,
$limit
=
0
)
{
if
(
$match
||
$limit
)
{
return
parent
::
getReferencableEntities
(
$match
,
$match_operator
,
$limit
);
return
parent
::
getReferenc
e
ableEntities
(
$match
,
$match_operator
,
$limit
);
}
$options
=
array
();
...
...
core/modules/views/lib/Drupal/views/Plugin/entity_reference/selection/ViewsSelection.php
View file @
0a91fd93
...
...
@@ -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::getReferenc
e
ableEntities().
*/
public
function
getReferencableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
,
$limit
=
0
)
{
public
function
getReferenc
e
ableEntities
(
$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::countReferenc
e
ableEntities().
*/
public
function
countReferencableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
)
{
$this
->
getReferencableEntities
(
$match
,
$match_operator
);
public
function
countReferenc
e
ableEntities
(
$match
=
NULL
,
$match_operator
=
'CONTAINS'
)
{
$this
->
getReferenc
e
ableEntities
(
$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::validateReferenc
e
ableEntities().
*/
public
function
validateReferencableEntities
(
array
$ids
)
{
public
function
validateReferenc
e
ableEntities
(
array
$ids
)
{
$handler_settings
=
$this
->
fieldDefinition
->
getFieldSetting
(
'handler_settings'
);
$display_name
=
$handler_settings
[
'view'
][
'display_name'
];
$arguments
=
$handler_settings
[
'view'
][
'arguments'
];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment