protected function registerProperties()
	{
		if (! static::$moduleConfig->shouldDiscover('registrars'))
		{
			return;
		}

		if (! static::$didDiscovery)
		{
			$locator         = \Config\Services::locator();
			$registrarsFiles = $locator->search('Config/Registrar.php');

			foreach ($registrarsFiles as $file)
			{
				$className = $locator->getClassname($file);
				static::$registrars[] = new $className();
			}

			static::$didDiscovery = true;
		}

		$shortName = (new \ReflectionClass($this))->getShortName();

		// Check the registrar class for a method named after this class' shortName
		foreach (static::$registrars as $callable)
		{
			// ignore non-applicable registrars
			if (! method_exists($callable, $shortName))
			{
				continue;
			}

			$properties = $callable::$shortName();

			if (! is_array($properties))
			{
				throw new \RuntimeException('Registrars must return an array of properties and their values.');
			}

			foreach ($properties as $property => $value)
			{
				if (isset($this->$property) && is_array($this->$property) && is_array($value))
				{
					$this->$property = array_merge($this->$property, $value);
				}
				else
				{
					$this->$property = $value;
				}
			}
		}
	}
protected function registerProperties()
	{
		if (! static::$moduleConfig->shouldDiscover('registrars'))
		{
			return;
		}

		if (! static::$didDiscovery)
		{
			$locator         = \Config\Services::locator();
			$registrarsFiles = $locator->search('Config/Registrar.php');

			foreach ($registrarsFiles as $file)
			{
				$className = $locator->getClassname($file);
				static::$registrars[] = new $className();
			}

			static::$didDiscovery = true;
		}

		$shortName = (new \ReflectionClass($this))->getShortName();

		// Check the registrar class for a method named after this class' shortName
		foreach (static::$registrars as $callable)
		{
			// ignore non-applicable registrars
			if (! method_exists($callable, $shortName))
			{
				continue;
			}

			$properties = $callable::$shortName();

			if (! is_array($properties))
			{
				throw new \RuntimeException('Registrars must return an array of properties and their values.');
			}

			foreach ($properties as $property => $value)
			{
				if (isset($this->$property) && is_array($this->$property) && is_array($value))
				{
					$this->$property = array_merge($this->$property, $value);
				}
				else
				{
					$this->$property = $value;
				}
			}
		}
	}
protected function registerProperties ( ) { if ( ! static :: $ moduleConfig -> shouldDiscover ( 'registrars' ) ) { return ; } if ( ! static :: $ didDiscovery ) { $ locator = \ Config \ Services :: locator ( ) ; $ registrarsFiles = $ locator -> search ( 'Config/Registrar.php' ) ; foreach ( $ registrarsFiles as $ file ) { $ className = $ locator -> getClassname ( $ file ) ; static :: $ registrars [ ] = new $ className ( ) ; } static :: $ didDiscovery = true ; } $ shortName = ( new \ ReflectionClass ( $ this ) ) -> getShortName ( ) ; // Check the registrar class for a method named after this class' shortName foreach ( static :: $ registrars as $ callable ) { // ignore non-applicable registrars if ( ! method_exists ( $ callable , $ shortName ) ) { continue ; } $ properties = $ callable :: $ shortName ( ) ; if ( ! is_array ( $ properties ) ) { throw new \ RuntimeException ( 'Registrars must return an array of properties and their values.' ) ; } foreach ( $ properties as $ property => $ value ) { if ( isset ( $ this -> $ property ) && is_array ( $ this -> $ property ) && is_array ( $ value ) ) { $ this -> $ property = array_merge ( $ this -> $ property , $ value ) ; } else { $ this -> $ property = $ value ; } } } }
Provides external libraries a simple way to register one or more
options into a config file.

@throws \ReflectionException
Provides external libraries a simple way to register one or more options into a config file .