Skip to content

Commit

Permalink
#47 Fixes bug when content field is empty; Refactors third-party serv…
Browse files Browse the repository at this point in the history
…ices (2)
  • Loading branch information
timurtripp committed Feb 14, 2024
1 parent 17d346a commit a12526e
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/SiteConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,27 +424,31 @@ public function attachExternalServiceIncludes(array &$variables, NodeInterface $
if ($node) {
$inclusiveGroup = $query->andConditionGroup()->condition('sitewide', FALSE);
$inclusiveGroup->condition('nodes.*', $node->id());
$exclusiveGroup->condition('nodes.*', [$node->id()], 'NOT IN');
$exclusiveGroup->condition($query->orConditionGroup()->condition('nodes.0', operator: 'IS NULL')->condition('nodes.*', [$node->id()], 'NOT IN'));
$query->condition($inclusiveGroup);
}
$query->condition($exclusiveGroup);
$results = $query->execute();
/** @var \Drupal\ucb_site_configuration\Entity\ExternalServiceIncludeInterface[] */
$externalServiceIncludeEntities = $storage->loadMultiple($results);
$externalServiceIncludeArrays = [];
foreach ($externalServiceIncludeEntities as $externalServiceInclude) {
$externalServiceName = $externalServiceInclude->getServiceName();
$externalServiceIncludeArrays[$externalServiceName][] = [
'id' => $externalServiceInclude->id(),
'label' => $externalServiceInclude->label(),
'service_name' => $externalServiceName,
'service_settings' => $externalServiceInclude->getServiceSettings(),
'sitewide' => $externalServiceInclude->isSitewide(),
];
}
foreach ($externalServiceIncludeArrays as $externalServiceName => $externalServiceIncludeArray) {
$variables['service_' . $externalServiceName . '_includes'] = $externalServiceIncludeArray;
$externalServiceEnabled = count($results) > 0;
if ($externalServiceEnabled) {
/** @var \Drupal\ucb_site_configuration\Entity\ExternalServiceIncludeInterface[] */
$externalServiceIncludeEntities = $storage->loadMultiple($results);
$externalServiceIncludeArrays = [];
foreach ($externalServiceIncludeEntities as $externalServiceInclude) {
$externalServiceName = $externalServiceInclude->getServiceName();
$externalServiceIncludeArrays[$externalServiceName][] = [
'id' => $externalServiceInclude->id(),
'label' => $externalServiceInclude->label(),
'service_name' => $externalServiceName,
'service_settings' => $externalServiceInclude->getServiceSettings(),
'sitewide' => $externalServiceInclude->isSitewide(),
];
}
foreach ($externalServiceIncludeArrays as $externalServiceName => $externalServiceIncludeArray) {
$variables['service_' . $externalServiceName . '_includes'] = $externalServiceIncludeArray;
}
}
$variables['external_service_enabled'] = $externalServiceEnabled;
}

/**
Expand Down

0 comments on commit a12526e

Please sign in to comment.