container = $container; } public function addFeed($serviceID, string $type, string $name, bool $configurable, bool $isAllowed) { if (!$isAllowed || ($configurable && !findModule(\Modules::FEED_GENERATOR))) { return; } $this->aliases[$type] = $name; $this->serviceIDs[$type] = $serviceID; if ($configurable) { $this->configurableIDs[] = $type; } } public function sortAliases() { $primary = []; $configurable = []; $other = []; foreach ($this->aliases as $key => $alias) { if ($key === 'configurable') { $primary[$key] = $alias; } elseif (($key === 'external') || ($key === 'deprecated')) { $other[$key] = $alias; } elseif ($this->isTypeConfigurable($key)) { $configurable[$key] = $alias; } else { $other[$key] = '[ZastaralĂ˝] '.$alias; } } array_multisort($configurable, SORT_STRING); array_multisort($other, SORT_STRING); $this->aliases = array_merge($primary, $configurable, $other); } public function getAliases(): array { return $this->aliases; } /** * @throws UnknownFeedTypeException */ public function getServiceByType(string $type): IFeed { if (!isset($this->serviceIDs[$type])) { // throw new UnknownFeedTypeException('Unknown feed type: '.$type); $type = 'deprecated'; } /** @var $feedService IFeed */ $feedService = $this->container->get($this->serviceIDs[$type]); return $feedService; } /** * @throws UnknownFeedTypeException */ public function getAliasByType(string $type): string { if (!isset($this->aliases[$type])) { throw new UnknownFeedTypeException($type); } return $this->aliases[$type]; } public function isTypeConfigurable(string $type): bool { return in_array($type, $this->configurableIDs); } }