protected function ViewsSelection::initializeView in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php \Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection::initializeView()
Initializes a view.
Parameters
string|null $match: (Optional) Text to match the label against. Defaults to NULL.
string $match_operator: (Optional) The operation the matching should be done with. Defaults to "CONTAINS".
int $limit: Limit the query to a given number of items. Defaults to 0, which indicates no limiting.
array|null $ids: Array of entity IDs. Defaults to NULL.
Return value
bool Return TRUE if the view was initialized, FALSE otherwise.
2 calls to ViewsSelection::initializeView()
- ViewsSelection::getReferenceableEntities in core/
modules/ views/ src/ Plugin/ EntityReferenceSelection/ ViewsSelection.php - Gets the list of referenceable entities.
- ViewsSelection::validateReferenceableEntities in core/
modules/ views/ src/ Plugin/ EntityReferenceSelection/ ViewsSelection.php - Validates which existing entities can be referenced.
File
- core/
modules/ views/ src/ Plugin/ EntityReferenceSelection/ ViewsSelection.php, line 191 - Contains \Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection.
Class
- ViewsSelection
- Plugin implementation of the 'selection' entity_reference.
Namespace
Drupal\views\Plugin\EntityReferenceSelectionCode
protected function initializeView($match = NULL, $match_operator = 'CONTAINS', $limit = 0, $ids = NULL) {
$handler_settings = $this->configuration['handler_settings'];
$view_name = $handler_settings['view']['view_name'];
$display_name = $handler_settings['view']['display_name'];
// Check that the view is valid and the display still exists.
$this->view = Views::getView($view_name);
if (!$this->view || !$this->view
->access($display_name)) {
drupal_set_message(t('The reference view %view_name cannot be found.', array(
'%view_name' => $view_name,
)), 'warning');
return FALSE;
}
$this->view
->setDisplay($display_name);
// Pass options to the display handler to make them available later.
$entity_reference_options = array(
'match' => $match,
'match_operator' => $match_operator,
'limit' => $limit,
'ids' => $ids,
);
$this->view->displayHandlers
->get($display_name)
->setOption('entity_reference_options', $entity_reference_options);
return TRUE;
}