src/models/data/SeoData.php
public function init ()
	{

		// Title
		// ---------------------------------------------------------------------

		$twig     = \Craft::$app->view->twig;
		$title    = array_filter($this->titleRaw);
		$template = $this->_getSetting('title');

		if (is_string($title)) $this->_titleTemplate = $title;
		else
		{
			$this->_titleTemplate = implode(
				'',
				array_map(
					function ($a) use ($twig, $title) {
						return array_key_exists($a['key'], $title)
							? twig_escape_filter($twig, $title[$a['key']])
							: $a['template'];
					},
					$template
				)
			);
		}

		// Description
		// ---------------------------------------------------------------------

		if (!empty($this->descriptionRaw))
			$this->_renderedDescription = $this->descriptionRaw;

		$this->_descriptionTemplate = $this->_getSetting('description');

		// Keywords
		// ---------------------------------------------------------------------

		if (!is_array($this->keywords))
			$this->keywords = [];

		// Social
		// ---------------------------------------------------------------------

		$fallback = $this->_getSocialFallback();

		foreach ($this->social as $key => $value)
		{
			if ($value === null)
				$this->social[$key] = new SocialData($key, $fallback);
			elseif (is_array($value))
				// FIXME
				$this->social[$key] = new SocialData($key, $fallback, $value);
		}

		// Robots
		// ---------------------------------------------------------------------

		// Fallback if robots empty
		if (empty($this->advanced['robots']))
			$this->advanced['robots'] = Seo::$i->getSettings()->robots ?? [];

		// Filter out empty robots
		$this->advanced['robots'] = array_filter($this->advanced['robots']);
	}
public function init ()
	{

		// Title
		// ---------------------------------------------------------------------

		$twig     = \Craft::$app->view->twig;
		$title    = array_filter($this->titleRaw);
		$template = $this->_getSetting('title');

		if (is_string($title)) $this->_titleTemplate = $title;
		else
		{
			$this->_titleTemplate = implode(
				'',
				array_map(
					function ($a) use ($twig, $title) {
						return array_key_exists($a['key'], $title)
							? twig_escape_filter($twig, $title[$a['key']])
							: $a['template'];
					},
					$template
				)
			);
		}

		// Description
		// ---------------------------------------------------------------------

		if (!empty($this->descriptionRaw))
			$this->_renderedDescription = $this->descriptionRaw;

		$this->_descriptionTemplate = $this->_getSetting('description');

		// Keywords
		// ---------------------------------------------------------------------

		if (!is_array($this->keywords))
			$this->keywords = [];

		// Social
		// ---------------------------------------------------------------------

		$fallback = $this->_getSocialFallback();

		foreach ($this->social as $key => $value)
		{
			if ($value === null)
				$this->social[$key] = new SocialData($key, $fallback);
			elseif (is_array($value))
				// FIXME
				$this->social[$key] = new SocialData($key, $fallback, $value);
		}

		// Robots
		// ---------------------------------------------------------------------

		// Fallback if robots empty
		if (empty($this->advanced['robots']))
			$this->advanced['robots'] = Seo::$i->getSettings()->robots ?? [];

		// Filter out empty robots
		$this->advanced['robots'] = array_filter($this->advanced['robots']);
	}
public function init ( ) { // Title // --------------------------------------------------------------------- $ twig = \ Craft :: $ app -> view -> twig ; $ title = array_filter ( $ this -> titleRaw ) ; $ template = $ this -> _getSetting ( 'title' ) ; if ( is_string ( $ title ) ) $ this -> _titleTemplate = $ title ; else { $ this -> _titleTemplate = implode ( '' , array_map ( function ( $ a ) use ( $ twig , $ title ) { return array_key_exists ( $ a [ 'key' ] , $ title ) ? twig_escape_filter ( $ twig , $ title [ $ a [ 'key' ] ] ) : $ a [ 'template' ] ; } , $ template ) ) ; } // Description // --------------------------------------------------------------------- if ( ! empty ( $ this -> descriptionRaw ) ) $ this -> _renderedDescription = $ this -> descriptionRaw ; $ this -> _descriptionTemplate = $ this -> _getSetting ( 'description' ) ; // Keywords // --------------------------------------------------------------------- if ( ! is_array ( $ this -> keywords ) ) $ this -> keywords = [ ] ; // Social // --------------------------------------------------------------------- $ fallback = $ this -> _getSocialFallback ( ) ; foreach ( $ this -> social as $ key => $ value ) { if ( $ value === null ) $ this -> social [ $ key ] = new SocialData ( $ key , $ fallback ) ; elseif ( is_array ( $ value ) ) // FIXME $ this -> social [ $ key ] = new SocialData ( $ key , $ fallback , $ value ) ; } // Robots // --------------------------------------------------------------------- // Fallback if robots empty if ( empty ( $ this -> advanced [ 'robots' ] ) ) $ this -> advanced [ 'robots' ] = Seo :: $ i -> getSettings ( ) -> robots ?? [ ] ; // Filter out empty robots $ this -> advanced [ 'robots' ] = array_filter ( $ this -> advanced [ 'robots' ] ) ; }
=========================================================================
=========================================================================