function ViewsConfigUpdater::processEntityArgumentUpdate
Same name in other branches
- 10 core/modules/views/src/ViewsConfigUpdater.php \Drupal\views\ViewsConfigUpdater::processEntityArgumentUpdate()
Processes arguments and convert 'numeric' to 'entity_target_id' if needed.
Note that since this update will trigger deprecations if called by views_view_presave(), we cannot rely on the usual handler-specific checking and processing. That would still hit views_view_presave(), even when invoked from post_update. We must directly update the view here, so that it's already correct by the time views_view_presave() sees it.
Parameters
\Drupal\views\ViewEntityInterface $view: The View being updated.
Return value
bool Whether the view was updated.
2 calls to ViewsConfigUpdater::processEntityArgumentUpdate()
- ViewsConfigUpdater::needsEntityArgumentUpdate in core/
modules/ views/ src/ ViewsConfigUpdater.php - Checks if 'numeric' arguments should be converted to 'entity_target_id'.
- ViewsConfigUpdater::updateAll in core/
modules/ views/ src/ ViewsConfigUpdater.php - Performs all required updates.
File
-
core/
modules/ views/ src/ ViewsConfigUpdater.php, line 229
Class
- ViewsConfigUpdater
- Provides a BC layer for modules providing old configurations.
Namespace
Drupal\viewsCode
public function processEntityArgumentUpdate(ViewEntityInterface $view) : bool {
$changed = FALSE;
$displays = $view->get('display');
foreach ($displays as &$display) {
if (isset($display['display_options']['arguments'])) {
foreach ($display['display_options']['arguments'] as $argument_id => $argument) {
$plugin_id = $argument['plugin_id'] ?? '';
if ($plugin_id === 'numeric') {
$argument_table_data = $this->viewsData
->get($argument['table']);
$argument_definition = $argument_table_data[$argument['field']]['argument'] ?? [];
if (isset($argument_definition['id']) && $argument_definition['id'] === 'entity_target_id') {
$argument['plugin_id'] = 'entity_target_id';
$argument['target_entity_type_id'] = $argument_definition['target_entity_type_id'];
$display['display_options']['arguments'][$argument_id] = $argument;
$changed = TRUE;
}
}
}
}
}
if ($changed) {
$view->set('display', $displays);
}
$deprecations_triggered =& $this->triggeredDeprecations['2640994'][$view->id()];
if ($this->deprecationsEnabled && $changed && !$deprecations_triggered) {
$deprecations_triggered = TRUE;
@trigger_error(sprintf('The update to convert "numeric" arguments to "entity_target_id" for entity reference fields for view "%s" is deprecated in drupal:10.3.0 and is removed from drupal:12.0.0. Profile, module and theme provided configuration should be updated. See https://www.drupal.org/node/3441945', $view->id()), E_USER_DEPRECATED);
}
return $changed;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.