Skip to content
This repository was archived by the owner on Jun 24, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Fixed configurations of degov_media_video confriguations

### Changed
- Views reference when argument field is empty doesn't try to set the argument,
so the default argument is calculated by the view itself.

## [1.13.1] - 11-12-2017
### Added
- Updated dependencies from deGov modules to keep lightning up to date.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function degov_paragraph_view_reference_field_widget_form_alter(&$element, \Drup
$element['argument']['#weight'] = $arguments_weight;
$element['argument']['#states'] = $argument_states;
$element['argument']['#suffix'] = '</details>';
$view_modes = \Drupal::service('entity_display.repository')
$view_modes = ['' => t('As defined in the view')] + \Drupal::service('entity_display.repository')
->getViewModeOptions($entity_type);
if (!in_array($extra_data['view_mode'], array_keys($view_modes))) {
$extra_data['view_mode'] = 'default';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,41 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$view_arguments_config[] = $argument_config;
}
}
// load the arguments from the field storage.
$arguments = [$argument];
if (preg_match('/\//', $argument)) {
$arguments = explode('/', $argument);
}
/** @var \Drupal\node\NodeInterface $node */
$node = \Drupal::routeMatch()->getParameter('node');
$token_service = \Drupal::token();
if (is_array($arguments)) {
foreach ($arguments as $index => $argument) {
// Check if there are any tokens that need to be replaced.
if (!empty($token_service->scan($argument))) {
$arguments[$index] = $token_service->replace($argument, ['node' => $node]);
}
// If the argument is not set in the field set the exception value.
if ($argument == '' && !empty($view_arguments_config[$index])) {
if (!empty($view_arguments_config[$index]['exception']['value'])) {
$arguments[$index] = $view_arguments_config[$index]['exception']['value'];
} else {
$arguments[$index] = 0;
if (!empty($argument)) {
// load the arguments from the field storage.
$arguments = [$argument];
if (preg_match('/\//', $argument)) {
$arguments = explode('/', $argument);
}
/** @var \Drupal\node\NodeInterface $node */
$node = \Drupal::routeMatch()->getParameter('node');
$token_service = \Drupal::token();
if (is_array($arguments)) {
foreach ($arguments as $index => $argument) {
// Check if there are any tokens that need to be replaced.
if (!empty($token_service->scan($argument))) {
$arguments[$index] = $token_service->replace($argument, ['node' => $node]);
}
// If there is a default value for the node, set it - we have the node object.
if ($view_arguments_config[$index]['default_argument_type'] == 'node' && $node instanceof NodeInterface) {
$arguments[$index] = $node->id();
// If the argument is not set in the field set the exception value.
if ($argument == '' && !empty($view_arguments_config[$index])) {
if (!empty($view_arguments_config[$index]['exception']['value'])) {
$arguments[$index] = $view_arguments_config[$index]['exception']['value'];
}
else {
$arguments[$index] = 0;
}
// If there is a default value for the node, set it - we have the node object.
if ($view_arguments_config[$index]['default_argument_type'] == 'node' && $node instanceof NodeInterface) {
$arguments[$index] = $node->id();
}
}
}
}
$view->setArguments($arguments);
}
// Set the view display and arguments.
$view->setDisplay($display_id);
$view->setArguments($arguments);

// Set number of available elements.
if (!empty($extra_data['page_limit']) && is_numeric($extra_data['page_limit'])) {
$limit = (int) $extra_data['page_limit'];
Expand Down