| @@ 41-71 (lines=31) @@ | ||
| 38 | $this->eventDispatcher = $eventDispatcher; |
|
| 39 | } |
|
| 40 | ||
| 41 | public function createUrlAlias( |
|
| 42 | Location $location, |
|
| 43 | $path, |
|
| 44 | $languageCode, |
|
| 45 | $forwarding = false, |
|
| 46 | $alwaysAvailable = false |
|
| 47 | ) { |
|
| 48 | $eventData = [ |
|
| 49 | $location, |
|
| 50 | $path, |
|
| 51 | $languageCode, |
|
| 52 | $forwarding, |
|
| 53 | $alwaysAvailable, |
|
| 54 | ]; |
|
| 55 | ||
| 56 | $beforeEvent = new BeforeCreateUrlAliasEvent(...$eventData); |
|
| 57 | if ($this->eventDispatcher->dispatch(URLAliasEvents::BEFORE_CREATE_URL_ALIAS, $beforeEvent)->isPropagationStopped()) { |
|
| 58 | return $beforeEvent->getUrlAlias(); |
|
| 59 | } |
|
| 60 | ||
| 61 | $urlAlias = $beforeEvent->hasUrlAlias() |
|
| 62 | ? $beforeEvent->getUrlAlias() |
|
| 63 | : parent::createUrlAlias($location, $path, $languageCode, $forwarding, $alwaysAvailable); |
|
| 64 | ||
| 65 | $this->eventDispatcher->dispatch( |
|
| 66 | URLAliasEvents::CREATE_URL_ALIAS, |
|
| 67 | new CreateUrlAliasEvent($urlAlias, ...$eventData) |
|
| 68 | ); |
|
| 69 | ||
| 70 | return $urlAlias; |
|
| 71 | } |
|
| 72 | ||
| 73 | public function createGlobalUrlAlias( |
|
| 74 | $resource, |
|
| @@ 73-103 (lines=31) @@ | ||
| 70 | return $urlAlias; |
|
| 71 | } |
|
| 72 | ||
| 73 | public function createGlobalUrlAlias( |
|
| 74 | $resource, |
|
| 75 | $path, |
|
| 76 | $languageCode, |
|
| 77 | $forwarding = false, |
|
| 78 | $alwaysAvailable = false |
|
| 79 | ) { |
|
| 80 | $eventData = [ |
|
| 81 | $resource, |
|
| 82 | $path, |
|
| 83 | $languageCode, |
|
| 84 | $forwarding, |
|
| 85 | $alwaysAvailable, |
|
| 86 | ]; |
|
| 87 | ||
| 88 | $beforeEvent = new BeforeCreateGlobalUrlAliasEvent(...$eventData); |
|
| 89 | if ($this->eventDispatcher->dispatch(URLAliasEvents::BEFORE_CREATE_GLOBAL_URL_ALIAS, $beforeEvent)->isPropagationStopped()) { |
|
| 90 | return $beforeEvent->getUrlAlias(); |
|
| 91 | } |
|
| 92 | ||
| 93 | $urlAlias = $beforeEvent->hasUrlAlias() |
|
| 94 | ? $beforeEvent->getUrlAlias() |
|
| 95 | : parent::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable); |
|
| 96 | ||
| 97 | $this->eventDispatcher->dispatch( |
|
| 98 | URLAliasEvents::CREATE_GLOBAL_URL_ALIAS, |
|
| 99 | new CreateGlobalUrlAliasEvent($urlAlias, ...$eventData) |
|
| 100 | ); |
|
| 101 | ||
| 102 | return $urlAlias; |
|
| 103 | } |
|
| 104 | ||
| 105 | public function removeAliases(array $aliasList) |
|
| 106 | { |
|