Uname: Linux gra108.truehost.cloud 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.2.26 [ PHP INFO ] PHP os: Linux
Server Ip: 87.98.244.154
Your Ip: 18.188.218.103
User: pumpbmko (2127) | Group: pumpbmko (2132)
Safe Mode: OFF
Disable Function:
allow_url_fopen, show_source, system, shell_exec, passthru, exec, phpinfo, mail, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apallow_url_fopen,show_source, system, shell_exec, passthru, exec, phpinfo, mail, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, ap

name : ComponentsRepository.php
<?php


namespace ColibriWP\Theme;

use ColibriWP\Theme\Core\ComponentInterface;
use ColibriWP\Theme\Core\Hooks;

class ComponentsRepository {

	private $entities = array();

	public function load() {
		$components = Hooks::prefixed_apply_filters( 'components', array() );

		foreach ( $components as $key => $class ) {

			$this->add( $key, $class );
		}
	}


	/**
	 * @param $id
	 *
	 * @return null|ComponentInterface
	 */
	private function getInstance( $id ) {

		if ( ! $this->entities[ $id ] ['instance'] ) {
			$class = $this->entities[ $id ]['class'];

			$this->entities[ $id ] = array(
				'class'    => $this->entities[ $id ]['class'],
				'instance' => new $class(),
			);
		}

		return $this->entities[ $id ]['instance'];
	}

	/**
	 * @param $id
	 *
	 * @return ComponentInterface|null
	 */
	public function getByName( $id ) {

		if ( array_key_exists( $id, $this->entities ) ) {
			return $this->getInstance( $id );
		}

		return null;
	}


	/**
	 * @return array
	 */
	public function getAllDefinitions() {
		$result = array();

		foreach ( $this->entities as $key => $entity ) {
			$result[ $key ] = $entity['class'];
		}

		return $result;
	}

	/**
	 * @param $component_name
	 * @param $class
	 */
	public function add( $component_name, $class ) {
		$this->entities[ $component_name ] = array(
			'class'    => $class,
			'instance' => null,
		);
	}
}
© 2025 GrazzMean-Shell