Skip to content

Commit

Permalink
oops previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Mar 16, 2022
1 parent 74bb1ae commit 46130cd
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Core/Executor/UrlAliasManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ protected function create($step)
throw new InvalidStepDefinitionException("The 'destination' and 'destination_location' keys can not be used at the same time to create a new urlalias.");
}
// be kind to users
if (!isset($step->dsl['source']) && isset($step->dsl['path'])) {
$step->dsl['source'] = $step->dsl['path'];
unset($step->dsl['path']);
}
if (!isset($step->dsl['source'])) {
if (!isset($step->dsl['source']) && !isset($step->dsl['path'])) {
throw new InvalidStepDefinitionException("The 'source' key is required to create a new urlalias.");
}

$path = $this->referenceResolver->resolveReference($step->dsl['source']);
if (isset($step->dsl['source'])) {
$path = $this->referenceResolver->resolveReference($step->dsl['source']);
} else {
$path = $this->referenceResolver->resolveReference($step->dsl['path']);
}

$languageCode = isset($step->dsl['language_code']) ? $this->referenceResolver->resolveReference($step->dsl['language_code']) : null;

Expand All @@ -52,11 +51,13 @@ protected function create($step)
if (isset($step->dsl['destination'])) {
$url = $urlAliasService->createGlobalUrlAlias($this->referenceResolver->resolveReference($step->dsl['destination']), $path, $languageCode, $forward, $alwaysAvailable);
} else {
/// @todo Should we resolve refs in $step->dsl['destination_location']? What if it is a remote_id in the form of 'reference:hello'
if (!is_int($step->dsl['destination_location']) && !ctype_digit($step->dsl['destination_location'])) {
$location = $this->repository->getLocationService()->loadLocationByRemoteId($step->dsl['destination_location']);
/// @todo Should we always resolve refs in $step->dsl['destination_location']? What if it is a remote_id in the form of 'reference:hello'
$destination = $this->referenceResolver->resolveReference($step->dsl['destination_location']);

if (!is_int($destination) && !ctype_digit($destination)) {
$location = $this->repository->getLocationService()->loadLocationByRemoteId($destination);
} else {
$location = $this->repository->getLocationService()->loadLocation($step->dsl['destination_location']);
$location = $this->repository->getLocationService()->loadLocation($destination);
}

$url = $urlAliasService->createUrlAlias($location, $path, $languageCode, $forward, $alwaysAvailable);
Expand Down

0 comments on commit 46130cd

Please sign in to comment.