diff --git a/site/app/Application/RouterFactory.php b/site/app/Application/RouterFactory.php index 6727cb74c..4894476f9 100644 --- a/site/app/Application/RouterFactory.php +++ b/site/app/Application/RouterFactory.php @@ -40,15 +40,6 @@ class RouterFactory private const ROOT_ONLY = ''; - /** @var array> of host => array of supported locales */ - private array $supportedLocales; - - /** @var array of locale => root domain */ - private array $rootDomainMapping; - - /** @var array, actions?:array>}>> */ - private array $translatedRoutes; - /** @var array>> */ private array $translatedPresenters = []; @@ -73,54 +64,25 @@ class RouterFactory private array $availableLocales; - public function __construct( - private Loader $blogPostLoader, - private Translator $translator, - ) { - $this->availableLocales = $this->translator->getAvailableLocales(); - } - - /** - * Set supported locales - * - * @param array> $supportedLocales array of host => array of supported locales - */ - public function setSupportedLocales(array $supportedLocales): void - { - $this->supportedLocales = $supportedLocales; - } - - - /** - * Set locale to root domain mapping. - * + * @param array> $supportedLocales host => array of supported locales * @param array $rootDomainMapping locale => root domain + * @param array, actions?:array>}>> $translatedRoutes */ - public function setLocaleRootDomainMapping(array $rootDomainMapping): void - { - $this->rootDomainMapping = $rootDomainMapping; - } - - - /** - * Get locale to root domain mapping. - * - * @return array $rootDomainMapping locale => root domain - */ - public function getLocaleRootDomainMapping(): array - { - return $this->rootDomainMapping; + public function __construct( + private readonly Loader $blogPostLoader, + private readonly Translator $translator, + private readonly array $supportedLocales, + private readonly array $rootDomainMapping, + private readonly array $translatedRoutes, + ) { + $this->availableLocales = $this->translator->getAvailableLocales(); + $this->setTranslatedPresentersAndActions(); } - /** - * @param array, actions?:array>}>> $translatedRoutes - */ - public function setTranslatedRoutes(array $translatedRoutes): void + private function setTranslatedPresentersAndActions(): void { - $this->translatedRoutes = $translatedRoutes; - foreach ($this->translatedRoutes as $module => $routes) { foreach ($routes as $presenter => $items) { foreach ($items['mask'] as $locale => $mask) { diff --git a/site/app/CompanyInfo/Ares.php b/site/app/CompanyInfo/Ares.php index 1eb87a20e..a48bde723 100644 --- a/site/app/CompanyInfo/Ares.php +++ b/site/app/CompanyInfo/Ares.php @@ -24,12 +24,10 @@ class Ares implements CompanyDataInterface */ private const STATUS_FOUND = 1; - private string $url; - - public function setUrl(string $url): void - { - $this->url = $url; + public function __construct( + private readonly string $url, + ) { } diff --git a/site/app/CompanyInfo/Info.php b/site/app/CompanyInfo/Info.php index 30ecad4f5..8cd9752a7 100644 --- a/site/app/CompanyInfo/Info.php +++ b/site/app/CompanyInfo/Info.php @@ -11,19 +11,15 @@ class Info { - private Ares $ares; - - private RegisterUz $registerUz; - private Cache $cache; - private bool $loadCompanyDataVisible = true; - - public function __construct(Ares $ares, RegisterUz $registerUz, Storage $cacheStorage) - { - $this->ares = $ares; - $this->registerUz = $registerUz; + public function __construct( + private readonly Ares $ares, + private readonly RegisterUz $registerUz, + Storage $cacheStorage, + private bool $loadCompanyDataVisible = true, + ) { $this->cache = new Cache($cacheStorage, self::class); } diff --git a/site/app/CompanyInfo/RegisterUz.php b/site/app/CompanyInfo/RegisterUz.php index 192397abb..b97fee7ad 100644 --- a/site/app/CompanyInfo/RegisterUz.php +++ b/site/app/CompanyInfo/RegisterUz.php @@ -23,15 +23,10 @@ class RegisterUz implements CompanyDataInterface private const COUNTRY_CODE = 'sk'; - private string $rootUrl; + private readonly string $rootUrl; - /** - * Root URL of the service, ends with a slash. - * - * @param string $rootUrl - */ - public function setRootUrl(string $rootUrl): void + public function __construct(string $rootUrl) { if ($rootUrl[strlen($rootUrl) - 1] !== '/') { $rootUrl .= '/'; diff --git a/site/app/Formatter/TexyFormatter.php b/site/app/Formatter/TexyFormatter.php index 9cd12474f..51b15e97e 100644 --- a/site/app/Formatter/TexyFormatter.php +++ b/site/app/Formatter/TexyFormatter.php @@ -70,19 +70,14 @@ public function __construct( private readonly LocaleLinkGenerator $localeLinkGenerator, private readonly LocaleUrls $blogPostLocaleUrls, private readonly DateTimeFormatter $dateTimeFormatter, + string $staticRoot, + string $imagesRoot, + string $locationRoot, ) { - $this->cacheNamespace = 'TexyFormatted' . '.' . $this->translator->getLocale(); - } - - - /** - * Set static content URL root. - * - * @param string $root - */ - public function setStaticRoot(string $root): void - { - $this->staticRoot = rtrim($root, '/'); + $this->staticRoot = rtrim($staticRoot, '/'); + $this->imagesRoot = trim($imagesRoot, '/'); + $this->locationRoot = rtrim($locationRoot, '/'); + $this->cacheNamespace = 'TexyFormatted.' . $this->translator->getLocale(); } @@ -97,17 +92,6 @@ public function getStaticRoot(): string } - /** - * Set images root directory. - * - * @param string $root - */ - public function setImagesRoot(string $root): void - { - $this->imagesRoot = trim($root, '/'); - } - - /** * Get absolute URL of the image. * @@ -120,17 +104,6 @@ public function getImagesRoot(string $filename): string } - /** - * Set location root directory. - * - * @param string $root - */ - public function setLocationRoot(string $root): void - { - $this->locationRoot = rtrim($root, '/'); - } - - /** * Set top heading level. * diff --git a/site/app/Http/SecurityHeaders.php b/site/app/Http/SecurityHeaders.php index 93d7daf05..5c53c3567 100644 --- a/site/app/Http/SecurityHeaders.php +++ b/site/app/Http/SecurityHeaders.php @@ -16,39 +16,34 @@ class SecurityHeaders private string $actionName; /** @var array */ - private array $permissionsPolicy; + private readonly array $permissionsPolicy; + /** + * @param array $permissionsPolicy + */ public function __construct( private readonly IRequest $httpRequest, private readonly IResponse $httpResponse, private readonly Config $contentSecurityPolicy, private readonly LocaleLinkGenerator $localeLinkGenerator, + array $permissionsPolicy, ) { - } - - - /** - * @param array $policy - */ - public function setPermissionsPolicy(array $policy): void - { - $permissionsPolicy = $policy; - $this->normalizePermissionsPolicyValues($permissionsPolicy); - $this->permissionsPolicy = $permissionsPolicy; + $this->permissionsPolicy = $this->normalizePermissionsPolicyValues($permissionsPolicy); } /** * @param array $values + * @return array */ - private function normalizePermissionsPolicyValues(array &$values): void + private function normalizePermissionsPolicyValues(array $values): array { foreach ($values as &$value) { if ($value === 'none' || $value === null) { $value = ''; } elseif (is_array($value)) { - $this->normalizePermissionsPolicyValues($value); + $value = $this->normalizePermissionsPolicyValues($value); } elseif ($value !== 'self') { $value = trim($value); if ($value !== '') { @@ -56,6 +51,7 @@ private function normalizePermissionsPolicyValues(array &$values): void } } } + return $values; } diff --git a/site/app/Post/Post.php b/site/app/Post/Post.php index ace44f3e2..b4e3be766 100644 --- a/site/app/Post/Post.php +++ b/site/app/Post/Post.php @@ -26,12 +26,10 @@ class Post /** @var string[]|null */ private ?array $locales = null; - private int $updatedInfoThreshold; - - /** @var array>> */ - private array $allowedTags; - + /** + * @param array>> $allowedTags + */ public function __construct( private Explorer $database, private Loader $loader, @@ -41,6 +39,8 @@ public function __construct( private LocaleLinkGenerator $localeLinkGenerator, private Tags $tags, private Translator $translator, + private readonly int $updatedInfoThreshold, + private readonly array $allowedTags, ) { } @@ -51,12 +51,6 @@ public function getUpdatedInfoThreshold(): int } - public function setUpdatedInfoThreshold(int $updatedInfoThreshold): void - { - $this->updatedInfoThreshold = $updatedInfoThreshold; - } - - /** * @return array>> */ @@ -66,15 +60,6 @@ public function getAllowedTags(): array } - /** - * @param array>> $allowedTags - */ - public function setAllowedTags(array $allowedTags): void - { - $this->allowedTags = $allowedTags; - } - - /** * @throws InvalidLinkException * @throws JsonException diff --git a/site/app/Talks/Talks.php b/site/app/Talks/Talks.php index 89f4e708b..4d5e0e85a 100644 --- a/site/app/Talks/Talks.php +++ b/site/app/Talks/Talks.php @@ -25,24 +25,20 @@ class Talks /** @var int */ private const SLIDE_MAX_HEIGHT = 450; - private Explorer $database; - - private TexyFormatter $texyFormatter; - /** * Slides root, just directory no FQND, no leading slash, no trailing slash. */ - private string $slidesRoot; + private readonly string $slidesRoot; /** * Static files root FQDN, no trailing slash. */ - private string $staticRoot; + private readonly string $staticRoot; /** * Physical location root directory, no trailing slash. */ - private string $locationRoot; + private readonly string $locationRoot; /** @var string[] */ private array $deleteFiles = []; @@ -63,46 +59,16 @@ class Talks ]; - public function __construct(Explorer $context, TexyFormatter $texyFormatter) - { - $this->database = $context; - $this->texyFormatter = $texyFormatter; - } - - - /** - * Set static content URL root. - * - * @param string $root - */ - public function setStaticRoot($root): void - { - $this->staticRoot = rtrim($root, '/'); - } - - - /** - * Set location root directory. - * - * @param string $root - */ - public function setLocationRoot($root): void - { - $this->locationRoot = rtrim($root, '/'); - } - - - /** - * Set slides root directory. - * - * Removes both leading and trailing forward slashes. - * - * @param string $root - * @param string $slidesRoot - */ - public function setSlidesRoot(string $root, string $slidesRoot): void - { - $this->slidesRoot = trim($root, '/') . '/' . trim($slidesRoot, '/'); + public function __construct( + private readonly Explorer $database, + private readonly TexyFormatter $texyFormatter, + string $staticRoot, + string $imagesRoot, + string $locationRoot, + ) { + $this->staticRoot = rtrim($staticRoot, '/'); + $this->slidesRoot = trim($imagesRoot, '/') . '/talks'; + $this->locationRoot = rtrim($locationRoot, '/'); } diff --git a/site/app/Test/ServicesTrait.php b/site/app/Test/ServicesTrait.php index c479292dc..510fd4038 100644 --- a/site/app/Test/ServicesTrait.php +++ b/site/app/Test/ServicesTrait.php @@ -129,7 +129,7 @@ public function getRouterFactory(): RouterFactory { static $service; if (!$service) { - $service = new RouterFactory($this->getBlogPostLoader(), $this->getTranslator()); + $service = new RouterFactory($this->getBlogPostLoader(), $this->getTranslator(), [], [], []); } return $service; } @@ -175,11 +175,14 @@ public function getLocaleLinkGenerator(): LocaleLinkGenerator } - public function getSecurityHeaders(): SecurityHeaders + /** + * @param array $permissionsPolicy + */ + public function getSecurityHeaders(array $permissionsPolicy): SecurityHeaders { static $service; if (!$service) { - $service = new SecurityHeaders($this->getHttpRequest(), $this->getHttpResponse(), $this->getCspConfig(), $this->getLocaleLinkGenerator()); + $service = new SecurityHeaders($this->getHttpRequest(), $this->getHttpResponse(), $this->getCspConfig(), $this->getLocaleLinkGenerator(), $permissionsPolicy); } return $service; } diff --git a/site/app/Tls/Certificates.php b/site/app/Tls/Certificates.php index f1da3c0c6..8980c718c 100644 --- a/site/app/Tls/Certificates.php +++ b/site/app/Tls/Certificates.php @@ -16,41 +16,18 @@ class Certificates { - /** @var array */ - private array $users; - - private int $hideExpiredAfter; - - + /** + * @param array $users + */ public function __construct( private readonly Explorer $database, private readonly CertificateFactory $certificateFactory, + private readonly array $users, + private readonly int $hideExpiredAfter, ) { } - /** - * Set users authentication info. - * - * @param array $users - */ - public function setUsers(array $users): void - { - $this->users = $users; - } - - - /** - * Set hide expired after interval. - * - * @param int $hideExpiredAfter in days - */ - public function setHideExpiredAfter(int $hideExpiredAfter): void - { - $this->hideExpiredAfter = $hideExpiredAfter; - } - - /** * @param string $user * @param string $key diff --git a/site/app/Training/Mails.php b/site/app/Training/Mails.php index ce9bac4e4..eb4367b2b 100644 --- a/site/app/Training/Mails.php +++ b/site/app/Training/Mails.php @@ -20,10 +20,6 @@ class Mails private const REMINDER_DAYS = 5; - private string $emailFrom; - - private string $phoneNumber; - public function __construct( private readonly Mailer $mailer, @@ -33,6 +29,8 @@ public function __construct( private readonly Venues $trainingVenues, private readonly TrainingFiles $trainingFiles, private readonly DateTimeFormatter $dateTimeFormatter, + private readonly string $emailFrom, + private readonly string $phoneNumber, ) { } @@ -86,18 +84,6 @@ public function sendSignUpMail( } - public function setEmailFrom(string $from): void - { - $this->emailFrom = $from; - } - - - public function setPhoneNumber(string $number): void - { - $this->phoneNumber = $number; - } - - /** * @return Row[] */ diff --git a/site/app/Training/Prices.php b/site/app/Training/Prices.php index ff8f81245..2406acacd 100644 --- a/site/app/Training/Prices.php +++ b/site/app/Training/Prices.php @@ -6,12 +6,9 @@ class Prices { - private ?float $vatRate; - - - public function setVatRate(float $vatRate): void - { - $this->vatRate = $vatRate; + public function __construct( + private readonly float $vatRate, + ) { } diff --git a/site/app/UpcKeys/RouterInterface.php b/site/app/UpcKeys/RouterInterface.php index eb4ecbd89..a5899f394 100644 --- a/site/app/UpcKeys/RouterInterface.php +++ b/site/app/UpcKeys/RouterInterface.php @@ -8,15 +8,6 @@ interface RouterInterface { - /** - * @param string[] $prefixes - */ - public function setPrefixes(array $prefixes): void; - - - public function setModel(string $model): void; - - /** * @return array> */ diff --git a/site/app/UpcKeys/Technicolor.php b/site/app/UpcKeys/Technicolor.php index a13af5ca7..b08cf8e0c 100644 --- a/site/app/UpcKeys/Technicolor.php +++ b/site/app/UpcKeys/Technicolor.php @@ -15,65 +15,16 @@ class Technicolor implements RouterInterface { - private Explorer $database; - - private string $url; - - private string $apiKey; - - /** @var string[] */ - private array $prefixes; - - private string $model; - - - public function __construct(Explorer $context) - { - $this->database = $context; - } - - /** - * Set URL used by API Gateway. - * - * @param string $url + * @param string[] $serialNumberPrefixes */ - public function setUrl(string $url): void - { - $this->url = $url; - } - - - /** - * Set API Key used by API Gateway. - * - * @param string $apiKey - */ - public function setApiKey(string $apiKey): void - { - $this->apiKey = $apiKey; - } - - - /** - * Set serial number prefixes to generate keys for. - * - * @param string[] $prefixes - */ - public function setPrefixes(array $prefixes): void - { - $this->prefixes = $prefixes; - } - - - /** - * Set router model. - * - * @param string $model - */ - public function setModel(string $model): void - { - $this->model = $model; + public function __construct( + private readonly Explorer $database, + private readonly string $apiUrl, + private readonly string $apiKey, + private readonly array $serialNumberPrefixes, + private readonly string $model, + ) { } @@ -84,7 +35,7 @@ public function setModel(string $model): void */ public function getModelWithPrefixes(): array { - return [$this->model => $this->prefixes]; + return [$this->model => $this->serialNumberPrefixes]; } @@ -138,7 +89,7 @@ public function saveKeys(string $ssid): bool */ private function generateKeys(string $ssid): array { - $data = Json::decode($this->callApi(sprintf($this->url, $ssid, implode(',', $this->prefixes)))); + $data = Json::decode($this->callApi(sprintf($this->apiUrl, $ssid, implode(',', $this->serialNumberPrefixes)))); $keys = array(); foreach (explode("\n", $data) as $line) { if (empty($line)) { diff --git a/site/app/UpcKeys/Ubee.php b/site/app/UpcKeys/Ubee.php index b8c8ff5d1..58c4bb7e1 100644 --- a/site/app/UpcKeys/Ubee.php +++ b/site/app/UpcKeys/Ubee.php @@ -13,34 +13,21 @@ class Ubee implements RouterInterface /** @var string */ private const OUI_UBEE = '647c34'; - private Explorer $database; - - private string $prefix; - - private string $model; - - - public function __construct(Explorer $context) - { - $this->database = $context; - } + private string $serialNumberPrefix; /** - * @param string[] $prefixes + * @param string[] $serialNumberPrefixes */ - public function setPrefixes(array $prefixes): void - { - if (count($prefixes) !== 1) { + public function __construct( + private readonly Explorer $database, + private readonly string $model, + array $serialNumberPrefixes, + ) { + if (count($serialNumberPrefixes) !== 1) { throw new RuntimeException('Ubee can has only one prefix'); } - $this->prefix = current($prefixes); - } - - - public function setModel(string $model): void - { - $this->model = $model; + $this->serialNumberPrefix = current($serialNumberPrefixes); } @@ -51,7 +38,7 @@ public function setModel(string $model): void */ public function getModelWithPrefixes(): array { - return [$this->model => [$this->prefix]]; + return [$this->model => [$this->serialNumberPrefix]]; } @@ -76,7 +63,7 @@ public function getKeys(string $ssid): array private function buildKey(int $mac, int $key): stdClass { $result = new stdClass(); - $result->serial = $this->prefix; + $result->serial = $this->serialNumberPrefix; $result->oui = self::OUI_UBEE; $result->mac = sprintf('%06x', $mac); $result->type = UpcKeys::SSID_TYPE_UNKNOWN; diff --git a/site/app/UpcKeys/UpcKeys.php b/site/app/UpcKeys/UpcKeys.php index fa21cd889..f1ca8eef6 100644 --- a/site/app/UpcKeys/UpcKeys.php +++ b/site/app/UpcKeys/UpcKeys.php @@ -37,9 +37,11 @@ class UpcKeys private array $keys; - public function addRouter(RouterInterface $router): void + public function __construct(RouterInterface ...$routers) { - $this->routers[get_class($router)] = $router; + foreach ($routers as $router) { + $this->routers[$router::class] = $router; + } } diff --git a/site/app/User/Manager.php b/site/app/User/Manager.php index 4f692967f..6b08167d4 100644 --- a/site/app/User/Manager.php +++ b/site/app/User/Manager.php @@ -44,12 +44,6 @@ class Manager implements Authenticator private StaticKey $passwordEncryption; - private string $returningUserCookie; - - private string $permanentLoginCookie; - - private string $permanentLoginInterval; - private ?string $authCookiesPath = null; @@ -60,6 +54,9 @@ public function __construct( Passwords $passwords, StaticKey $passwordEncryption, LinkGenerator $linkGenerator, + private readonly string $returningUserCookie, + private readonly string $permanentLoginCookie, + private readonly string $permanentLoginInterval, ) { $this->database = $context; $this->httpRequest = $httpRequest; @@ -191,29 +188,6 @@ public function isReturningUser(): bool } - public function setReturningUserCookie(string $cookie): void - { - $this->returningUserCookie = $cookie; - } - - - public function setPermanentLoginCookie(string $cookie): void - { - $this->permanentLoginCookie = $cookie; - } - - - /** - * Set permanent login interval. - * - * @param string $interval - */ - public function setPermanentLoginInterval(string $interval): void - { - $this->permanentLoginInterval = $interval; - } - - /** * Hash token used for permanent login. * diff --git a/site/app/Www/Presenters/PgpPresenter.php b/site/app/Www/Presenters/PgpPresenter.php index 8bdb2cf86..31c062451 100644 --- a/site/app/Www/Presenters/PgpPresenter.php +++ b/site/app/Www/Presenters/PgpPresenter.php @@ -6,10 +6,11 @@ class PgpPresenter extends BasePresenter { - /** - * Physical location root directory, no trailing slash. - */ - private string $locationRoot; + public function __construct( + private readonly string $locationRoot, + ) { + parent::__construct(); + } public function renderDefault(): void @@ -19,10 +20,4 @@ public function renderDefault(): void $this->template->key = file_get_contents("{$this->locationRoot}/{$keyFile}"); } - - public function setLocationRoot(string $locationRoot): void - { - $this->locationRoot = $locationRoot; - } - } diff --git a/site/config/presenters.neon b/site/config/presenters.neon index 3f257c1f3..5b9180319 100644 --- a/site/config/presenters.neon +++ b/site/config/presenters.neon @@ -10,10 +10,7 @@ services: - MichalSpacekCz\Www\Presenters\ForbiddenPresenter - MichalSpacekCz\Www\Presenters\HomepagePresenter - MichalSpacekCz\Www\Presenters\InterviewsPresenter - pgpPresenter: - factory: MichalSpacekCz\Www\Presenters\PgpPresenter - setup: - - setLocationRoot(%domain.locationRoot%) + - MichalSpacekCz\Www\Presenters\PgpPresenter(locationRoot: %domain.locationRoot%) - MichalSpacekCz\Www\Presenters\PhotoPresenter - MichalSpacekCz\Www\Presenters\PostPresenter - MichalSpacekCz\Www\Presenters\RedirectPresenter diff --git a/site/config/services.neon b/site/config/services.neon index 680b8f35d..260d16e67 100644 --- a/site/config/services.neon +++ b/site/config/services.neon @@ -1,39 +1,20 @@ services: webApplication: MichalSpacekCz\Application\WebApplication(fqdn: %domain.fqdn%) application: Nette\Application\Application - routerFactory: - factory: MichalSpacekCz\Application\RouterFactory - setup: - - setSupportedLocales(%locales.supported%) - - setLocaleRootDomainMapping(%locales.rootDomainMapping%) - - setTranslatedRoutes(%translatedRoutes.presenters%) + routerFactory: MichalSpacekCz\Application\RouterFactory(supportedLocales: %locales.supported%, rootDomainMapping: %locales.rootDomainMapping%, translatedRoutes: %translatedRoutes.presenters%) router: @routerFactory::createRouter localeLinkGenerator: MichalSpacekCz\Application\LocaleLinkGenerator - texyFormatter: - factory: MichalSpacekCz\Formatter\TexyFormatter - setup: - - setStaticRoot(%domain.sharedStaticRoot%) - - setImagesRoot(%domain.imagesRoot%) - - setLocationRoot(%domain.locationRoot%) + texyFormatter: MichalSpacekCz\Formatter\TexyFormatter(staticRoot: %domain.sharedStaticRoot%, imagesRoot: %domain.imagesRoot%, locationRoot: %domain.locationRoot%) latte.templateFactory: MichalSpacekCz\Templating\TemplateFactory redirections: MichalSpacekCz\Http\Redirections httpStreamContext: MichalSpacekCz\Http\HttpStreamContext articles: MichalSpacekCz\Articles\Articles - talks: - factory: MichalSpacekCz\Talks\Talks - setup: - - setStaticRoot(%domain.sharedStaticRoot%) - - setLocationRoot(%domain.locationRoot%) - - setSlidesRoot(%domain.imagesRoot%, 'talks') + talks: MichalSpacekCz\Talks\Talks(staticRoot: %domain.sharedStaticRoot%, locationRoot: %domain.locationRoot%, imagesRoot: %domain.imagesRoot%) trainings: MichalSpacekCz\Training\Trainings companyTrainings: MichalSpacekCz\Training\CompanyTrainings interviews: MichalSpacekCz\Interviews\Interviews trainingApplications: MichalSpacekCz\Training\Applications(emailEncryption: @emailEncryption) - trainingMails: - factory: MichalSpacekCz\Training\Mails - setup: - - setEmailFrom('Michal Špaček ') - - setPhoneNumber(%contact.phoneNumber%) + trainingMails: MichalSpacekCz\Training\Mails(emailFrom: 'Michal Špaček ', phoneNumber: %contact.phoneNumber%) trainingDates: MichalSpacekCz\Training\Dates trainingVenues: MichalSpacekCz\Training\Venues trainingStatuses: MichalSpacekCz\Training\Statuses @@ -42,77 +23,35 @@ services: trainingFiles: MichalSpacekCz\Training\Files\TrainingFiles trainingLocales: MichalSpacekCz\Training\Locales trainingReviews: MichalSpacekCz\Training\Reviews - trainingPrices: - factory: MichalSpacekCz\Training\Prices - setup: - - setVatRate(%vatRate%) + trainingPrices: MichalSpacekCz\Training\Prices(vatRate: %vatRate%) vranaResolver: MichalSpacekCz\Training\Resolver\Vrana - authenticator: - factory: MichalSpacekCz\User\Manager(passwordEncryption: @passwordEncryption) - setup: - - setPermanentLoginCookie(%permanentLogin.cookie%) - - setPermanentLoginInterval(%permanentLogin.interval%) - - setReturningUserCookie(%returningUser.cookie%) + authenticator: MichalSpacekCz\User\Manager(passwordEncryption: @passwordEncryption, permanentLoginCookie: %permanentLogin.cookie%, permanentLoginInterval: %permanentLogin.interval%, returningUserCookie: %returningUser.cookie%) embed: MichalSpacekCz\Templating\Embed httpResponse: setup: - $cookieSecure(true) dateTimeFormatter: MichalSpacekCz\DateTime\DateTimeFormatter(@translation.translator::getDefaultLocale()) filters: MichalSpacekCz\Templating\Filters - securityHeaders: - factory: MichalSpacekCz\Http\SecurityHeaders - setup: - - setPermissionsPolicy(%permissionsPolicy%) + securityHeaders: MichalSpacekCz\Http\SecurityHeaders(permissionsPolicy: %permissionsPolicy%) security.passwords: Nette\Security\Passwords(::PASSWORD_ARGON2ID, [memory_cost: 65536, time_cost: 16, threads: 16]) passwordEncryption: Spaze\Encryption\Symmetric\StaticKey('password', %encryption.keys%, %encryption.activeKeyIds%) emailEncryption: Spaze\Encryption\Symmetric\StaticKey('email', %encryption.keys%, %encryption.activeKeyIds%) sessionEncryption: Spaze\Encryption\Symmetric\StaticKey('session', %encryption.keys%, %encryption.activeKeyIds%) - companyInfo: - factory: MichalSpacekCz\CompanyInfo\Info - setup: - - setLoadCompanyDataVisible(%loadCompanyDataVisible%) - ares: - factory: MichalSpacekCz\CompanyInfo\Ares - setup: - - setUrl(%ares.url%) - registerUz: - factory: MichalSpacekCz\CompanyInfo\RegisterUz - setup: - - setRootUrl(%registerUz.rootUrl%) - upcKeys: - factory: MichalSpacekCz\UpcKeys\UpcKeys - setup: - - addRouter(@upcKeysTechnicolor) - - addRouter(@upcKeysUbee) - upcKeysTechnicolor: - factory: MichalSpacekCz\UpcKeys\Technicolor(@database.upcKeys.context) - setup: - - setUrl(%awsLambda.upcKeys.url%) - - setApiKey(%awsLambda.upcKeys.apiKey%) - - setModel(%upcKeys.technicolor.model%) - - setPrefixes(%upcKeys.technicolor.prefixes%) - upcKeysUbee: - factory: MichalSpacekCz\UpcKeys\Ubee(@database.upcKeys.context) - setup: - - setModel(%upcKeys.ubee.model%) - - setPrefixes(%upcKeys.ubee.prefixes%) + companyInfo: MichalSpacekCz\CompanyInfo\Info(loadCompanyDataVisible: %loadCompanyDataVisible%) + ares: MichalSpacekCz\CompanyInfo\Ares(url: %ares.url%) + registerUz: MichalSpacekCz\CompanyInfo\RegisterUz(rootUrl: %registerUz.rootUrl%) + upcKeys: MichalSpacekCz\UpcKeys\UpcKeys(routers: [@upcKeysTechnicolor, @upcKeysUbee]) + upcKeysTechnicolor: MichalSpacekCz\UpcKeys\Technicolor(@database.upcKeys.context, apiUrl: %awsLambda.upcKeys.url%, apiKey: %awsLambda.upcKeys.apiKey%, model: %upcKeys.technicolor.model%, serialNumberPrefixes: %upcKeys.technicolor.prefixes%) + upcKeysUbee: MichalSpacekCz\UpcKeys\Ubee(@database.upcKeys.context, model: %upcKeys.ubee.model%, serialNumberPrefixes: %upcKeys.ubee.prefixes%) pulseCompanies: MichalSpacekCz\Pulse\Companies(@database.pulse.context) pulseSites: MichalSpacekCz\Pulse\Sites(@database.pulse.context) pulsePasswords: MichalSpacekCz\Pulse\Passwords(@database.pulse.context) pulsePasswordsRating: MichalSpacekCz\Pulse\Passwords\Rating pulsePasswordsSorting: MichalSpacekCz\Pulse\Passwords\PasswordsSorting - blogPost: - factory: MichalSpacekCz\Post\Post(exportsCache: Nette\Caching\Cache(namespace: MichalSpacekCz\Feed\Exports::class)) - setup: - - setUpdatedInfoThreshold(%blog.updatedInfoThreshold%) - - setAllowedTags(%blog.allowedTags%) + blogPost: MichalSpacekCz\Post\Post(exportsCache: Nette\Caching\Cache(namespace: MichalSpacekCz\Feed\Exports::class), updatedInfoThreshold: %blog.updatedInfoThreshold%, allowedTags: %blog.allowedTags%) blogPostLoader: MichalSpacekCz\Post\Loader blogPostLocaleUrls: MichalSpacekCz\Post\LocaleUrls - certificatesApi: - factory: MichalSpacekCz\Tls\Certificates - setup: - - setUsers(%certificatesApi.users%) - - setHideExpiredAfter(%certificatesApi.hideExpiredAfter%) + certificatesApi: MichalSpacekCz\Tls\Certificates(users: %certificatesApi.users%, hideExpiredAfter: %certificatesApi.hideExpiredAfter%) certificatesApiClient: MichalSpacekCz\Tls\CertificatesApiClient certificateGatherer: MichalSpacekCz\Tls\CertificateGatherer certificateMonitor: MichalSpacekCz\Tls\CertificateMonitor diff --git a/site/tests/Http/SecurityHeadersTest.phpt b/site/tests/Http/SecurityHeadersTest.phpt index e31b0a97f..81f25c10f 100644 --- a/site/tests/Http/SecurityHeadersTest.phpt +++ b/site/tests/Http/SecurityHeadersTest.phpt @@ -30,7 +30,16 @@ class SecurityHeadersTest extends TestCase { $this->httpResponse = $this->getHttpResponse(); $this->cspConfig = $this->getCspConfig(); - $this->securityHeaders = $this->getSecurityHeaders(); + $this->securityHeaders = $this->getSecurityHeaders([ + 'camera' => 'none', + 'geolocation' => null, + 'midi' => [ + 'self', + 'none', + ' ', + 'https://example.com', + ], + ]); $this->cspConfig->setPolicy([ '*.*' => [ @@ -49,16 +58,6 @@ class SecurityHeadersTest extends TestCase public function testSendHeaders(): void { $this->securityHeaders->setCsp('Foo', 'bar'); - $this->securityHeaders->setPermissionsPolicy([ - 'camera' => 'none', - 'geolocation' => null, - 'midi' => [ - 'self', - 'none', - ' ', - 'https://example.com', - ], - ]); $this->securityHeaders->sendHeaders(); $expected = [ 'content-security-policy' => "script-src 'none' example.com; form-action 'self'", diff --git a/site/tests/Training/PricesTest.phpt b/site/tests/Training/PricesTest.phpt index afb7e0363..1940ce8a0 100644 --- a/site/tests/Training/PricesTest.phpt +++ b/site/tests/Training/PricesTest.phpt @@ -17,8 +17,7 @@ class PricesTest extends TestCase public function setUp() { - $this->prices = new Prices(); - $this->prices->setVatRate(0.21); + $this->prices = new Prices(0.21); }