skipSeo = $skip; } /** * Init seo template * @param SeoTemplate|null $template * @return SeoTemplate|null */ public function useSeoTemplate($template = null) { if (! $this->seo) { $this->seo = $template ?? (new SeoTemplate()); } return $this->seo; } /** * Get seo page settings * @param bool $fill * @param array $with * @return SeoTemplate */ public function seoTemplate($fill = false, array $with = []) { if ($fill) { $this->seo->with($with); $this->seoSettings(); $this->seo->title( $this->getTitle() ); } return $this->seo; } /** * Set seo template settings key & group * @param string $key * @param string $group * @return SeoTemplate */ public function withSeoSettings(string $key, string $group) { return $this->seo->setupSettings($key, $group); } /** * Has seo template settings * @param string|null $group * @param string|null $key * @return bool */ public function hasSeoSettings(?string $group = null, ?string $key = null) { if ($group !== null) { return ( $this->seo->getSettingsGroup() === $group && ( is_null($key) || $this->seo->getSettingsKey() === $key ) ); } return $this->seo->getSettingsConfigKey() !== ''; } /** * Use regions seo placeholders * @return void */ public function seoMacrosRegions() { Geo::addRegionsSeoPlaceholders($this->seo); } /** * Fill regions seo placeholders * @param int|null $id active region id * @return array */ public function seoMacrosRegionsData(?int $id = null) { return Geo::addRegionsSeoPlaceholders($this->seo, true, $id); } /** * Проверка URL текущего запроса на обязательное наличие/отсутствие завершающего слеша * @param bool $required true - URL должен обязательно завершаться слешем, * false - URL должен обязательно быть без завершающего слеша * @param array $opts ['status' - статус редиректа, 'throw' - Response исключение] * @return \bff\http\Response|false * @throws \bff\exception\ResponseException */ public function seoCorrectUrlEndSlash($required = true, array $opts = []) { return SEO::urlCorrectionEndSlash($required, $opts); } /** * Active landing page data * @return mixed */ public function seoLandingPage() { return SEO::landingPage(); } /** * Set seo meta-tags for page * @param array $data @ref page data * @param array $opts extra options [landing-skip, divider] * @return void */ public function seoApply(array &$data = [], array $opts = []) { if ($data === []) { $data = &$this->data; } SEO::i()->applyTemplate($this->seo, $data, $opts); } /** * Apply seo settings * @return void */ abstract public function seo(); /** * Declare seo settings * @return void */ public function seoSettings() { } }