Get presenter
Checks if instance of $className exists in $presenters,
initiates a new one if not, and returns the instance.

@return Presenter
342403
protected function getPresenter($className)
    {
        if (!isset($this->presenters[$className])) {
            $this->presenters[$className] = new $className($this->helperSet);
        }
        return $this->presenters[$className];
    }
433097
public function present( array $options = [] ) {
		$class_reference = $this->get_presenter_class_name();

		if ( null !== $class_reference ) {
			$instance = new $class_reference( $this, $options );

			if ( $instance instanceof Factory ) {
				return $instance->build();
			}

			return to_array( $instance );
		}

		return to_array( $this );
	}
9165
public function getPresenter(): ?IconSetInterface
    {
        static $presenter;

        if ($presenter instanceof IconSetInterface) {
            return $presenter;
        }

        return $presenter = $this->hasPresenter() ? app($this->icons_presenter_class) : null;
    }
1103790
protected function getClassService()
    {
        if (is_null($this->service)) {
            $this->service = DeliveryTemplateService::singleton();
        }
        return $this->service;
    }
1010920
public function get($name, $parameters = null)
    {
        $instance = parent::get($name, $parameters);

        if (is_object($instance) && $instance instanceof EventsAwareInterface) {
            if (!$instance->getEventsManager() && ($eventsManager = $this->getEventsManager())) {
                $instance->setEventsManager($eventsManager);
            }
        }

        return $instance;
    }
514307
final public static function getInstance()
    {
        $className = get_called_class();
        if (!isset(self::$_instances[$className])) {
            $instance = new $className();
            /* @var SingleTon $instance */
            $instance->init();
            self::$_instances[$className] = $instance;
        }
        return self::$_instances[$className];
    }
79132
public static function get(string $classname)
    {
        return new class($classname)
        {
            private static $rc;

            public function __construct(string $classname)
            {
                self::$rc = new \ReflectionClass($classname);
            }

            /**
             * Call static method of your class.
             * @param  string $name
             * @param  array  $args
             * @return mixed
             */
            public static function __callStatic(string $name, array $args)
            {
                $rc = self::$rc;
                if (method_exists($rc->name, $name)) {
                    $rm = $rc->getMethod($name);
                    if (!$rm->isStatic()) {
                        throw new ProxyException(
                            "Non-static method called statically: " .
                            "$rc->name::$name()");
                    }
                    $rm->setAccessible(true);
                    return $rm->invokeArgs(null, $args);
                }
                if (method_exists($rc->name, '__callStatic')) {
                    return $rc->name::$name(...$args);
                }
                throw new ProxyException(
                    "Call to undefined method: $rc->name::$name()");
            }

            private static function getStaticReflectionProperty(string $name) : \ReflectionProperty
            {
                $rc = self::$rc;
                if (property_exists($rc->name, $name)) {
                    $rp = $rc->getProperty($name);
                    if (!$rp->isStatic()) {
                        throw new ProxyException(
                            "Access to undeclared static property: " .
                            "$rc->name::\$$name");
                    }
                    $rp->setAccessible(true);
                    return $rp;
                }
                throw new ProxyException(
                    "Access to undeclared static property: " .
                    "$rc->name::\$$name");
            }

            /**
             * Get static property of your class.
             * If you want to call your own "static function getStatic()":
             *   $proxy->__callStatic('getStatic', $args)
             * @param  string $name
             * @return mixed
             */
            public static function getStatic(string $name)
            {
                return self::getStaticReflectionProperty($name)->getValue();
            }

            /**
             * Set static property of your class.
             * If you want to call your own "static function setStatic()":
             *   $proxy->__callStatic('setStatic', $args)
             * @param string $name
             * @param mixed  $value
             */
            public static function setStatic(string $name, $value)
            {
                self::getStaticReflectionProperty($name)->setValue($name, $value);
            }

            /**
             * Create anonymous proxy object of your class.
             * If you want to call your own "static function new()":
             *   $proxy->__callStatic('new', $args)
             * @param  mixed ...$args
             * @return class@anonymous
             */
            public static function new(...$args)
            {
                return self::newInstance($args);
            }

            /**
             * Create anonymous proxy object of your class without constructor.
             * If you want to call your own "static function newWithoutConstructor()":
             *   $proxy->__callStatic('newWithoutConstructor', $args)
             * @return class@anonymous
             */
            public static function newWithoutConstructor()
            {
                return self::newInstance();
            }

            private static function newInstance(array $args = null)
            {
                return new class(self::$rc, $args)
                {
                    private $ro;
                    private $ins;

                    public function __construct(\ReflectionClass $rc, array $args = null)
                    {
                        $this->ins = $rc->newInstanceWithoutConstructor();
                        if ($args !== null && $con = $rc->getConstructor()) {
                            $con->setAccessible(true);
                            $con->invokeArgs($this->ins, $args);
                        }
                        $this->ro = new \ReflectionObject($this->ins);
                    }

                    /**
                     * Call instance method of your class.
                     * @param  string $name
                     * @param  array  $args
                     * @return mixed
                     */
                    public function __call(string $name, array $args)
                    {
                        if (method_exists($this->ro->name, $name)) {
                            $rm = $this->ro->getMethod($name);
                            $rm->setAccessible(true);
                            return $rm->invokeArgs($this->ins, $args);
                        }
                        if (method_exists($this->ro->name, '__call')) {
                            return $this->ins->$name(...$args);
                        }
                        throw new ProxyException(
                            "Call to undefined method: " .
                            "{$this->ro->name}::$name()");
                    }

                    private function getReflectionProperty(string $name)
                    {
                        if (property_exists($this->ins, $name)) {
                            $rp = $this->ro->getProperty($name);
                            $rp->setAccessible(true);
                            return $rp;
                        }
                        throw new ProxyException(
                            "Undefined property: {$this->ro->name}::\$$name");
                    }

                    /**
                     * Get property of your object.
                     * @param  string $name
                     * @return mixed
                     */
                    public function __get(string $name)
                    {
                        try {
                            return $this->getReflectionProperty($name)
                                        ->getValue($this->ins);
                        } catch (ProxyException $e) {
                            try {
                                return $this->__call('__get', [$name]);
                            } catch (ProxyException $_) {
                                throw $e;
                            }
                        }
                    }

                    /**
                     * Set property of your object.
                     * @param  string $name
                     * @param  mixed  $value
                     */
                    public function __set(string $name, $value)
                    {
                        try {
                            $property = $this->getReflectionProperty($name);
                            $property->setValue($this->ins, $value);
                        } catch (ProxyException $e) {
                            try {
                                $this->__call('__set', [$name, $value]);
                                return;
                            } catch (ProxyException $_) { } // If __set() is undefined,
                                                            // fallback to the actual property.
                            if (isset($property)) {
                                throw $e; // Static property exists,
                                          // so you cannot create a new field.
                            } else {
                                $this->ins->$name = $value; // Property does not exists
                                                            // so you can create a new field.
                            }
                        }
                    }
                };
            }
        };
    }
981333
protected function getInstance($classname, $params)
    {
        $components = UIComponentsRegistry::get('ui-components');
        if (is_null($components)) {
            return false;
        }
        $object = $components->first(function ($value, $key) use($classname) {
            return $value instanceof $classname;
        });
        if (!$object) {
            return false;
        }

        $attributes       = array_only(array_get($params, 'data'), ['x', 'y', 'width', 'height', 'disabled', 'id']);
        $attributes['id'] = isset($params['id']) ? $params['id'] : null;

        $object->setAttributes($attributes);
        return $object;
    }
914968
public function get($instanceName) {
		if (!isset($this->objectInstances[$instanceName]) || $this->objectInstances[$instanceName] == null) {
			$this->instantiateComponent($instanceName);
		}
		return $this->objectInstances[$instanceName];
	}
834882
public function getHandlerInstance($name) {
        if (is_array($this->eventHandlers[$name])) {
            // The listener has not been initialized
            $className = $this->eventHandlers[$name]['handler'];
            $params = $this->eventHandlers[$name]['params'];
            $handler = new $className($params ?: null);

            // Run initializers
            foreach ($this->initializers as $initializer) {
                $initializer->initialize($handler);
            }

            $this->eventHandlers[$name] = $handler;
        }

        return $this->eventHandlers[$name];
    }
1320788
public static function instantiate($className)
    {
        $objectManager = self::get()->getObjectManager();
        $args = func_get_args();

        if (1 === count($args)) {
            return $objectManager->get($className);
        }

        return call_user_func_array([$objectManager, 'get'], $args);
    }
112727
public static function &GetInstance()
    {
        static $oInstance = null;
        if (is_null($oInstance)) {
            $oInstance = new self();
            TPkgCmsEventManager::GetInstance()->RegisterObserver(TPkgCmsEvent::CONTEXT_CORE, TPkgCmsEvent::NAME_PRE_OUTPUT_CALLBACK_FUNCTION, $oInstance);
        }

        return $oInstance;
    }
1187599
public static function instance($className = __CLASS__)
    {
        if (!isset(self::$instances[$className])) {
            self::$instances[$className] = new $className;
        }

        return self::$instances[$className];
    }
655931
public final function get($className)
   {
       try {
           return $this->cache->get(... func_get_args());
       } catch (NotFoundException $e) {
           try {
               $service = $this->resolver->resolve($className, $this->cache);
           } catch (NotFoundException $e) {
               throw $e;
           } catch (ContainerException $e) {
               throw $e;
           }
       }
       $this->cache->set($className, $service);
       return $this->cache->get($className);
   }
194593
public function getReflectionClass($className)
    {

        // check if we've already initialized the reflection class
        if (isset($this->reflectionClasses[$className]) === false) {
            $this->reflectionClasses[$className] = $this->newReflectionClass($className);
        }

        // return the reflection class instance
        return $this->reflectionClasses[$className];
    }
760924
public static function getInstance()
    {
        $class = get_called_class();

        if (!isset(self::$instances[$class])) {
            $container = StaticContainer::getContainer();

            $refl = new \ReflectionClass($class);

            if (!$refl->getConstructor() || $refl->getConstructor()->isPublic()) {
                self::$instances[$class] = $container->get($class);
            } else {
                /** @var LoggerInterface $logger */
                $logger = $container->get('Psr\Log\LoggerInterface');

                // BC with API defining a protected constructor
                $logger->notice('The API class {class} defines a protected constructor which is deprecated, make the constructor public instead', array('class' => $class));
                self::$instances[$class] = new $class;
            }
        }

        return self::$instances[$class];
    }
1369953
public function getInstance($className)
    {
        switch ($className) {
            case '\\Zepi\\Core\\AccessControl\\Manager\\AccessControlManager':
                if ($this->accessControlManager === null) {
                    $dataSourceManager = $this->framework->getDataSourceManager();
                    
                    $this->accessControlManager = $this->framework->initiateObject($className, array(
                        'accessEntitiesDataSource' => $dataSourceManager->getDataSource('\\Zepi\\Core\\AccessControl\\DataSource\\AccessEntitiesDataSourceInterface'),
                        'permissionsDataSource' => $dataSourceManager->getDataSource('\\Zepi\\Core\\AccessControl\\DataSource\\PermissionsDataSourceInterface')
                    ));
                }
                
                return $this->accessControlManager;
            break;
            
            case '\\Zepi\\Core\\AccessControl\\Manager\\AccessLevelManager':
                if ($this->accessLevelManager === null) {
                    $accessLevelsObjectBackend = $this->framework->initiateObject('\Zepi\Turbo\Backend\FileObjectBackend', array(
                        'path' => $this->framework->getRootDirectory() . '/data/access-levels.data'
                    ));
                    
                    $this->accessLevelManager = $this->framework->initiateObject($className, array(
                        'accessLevelObjectBackend' => $accessLevelsObjectBackend
                    ));
                    $this->accessLevelManager->initializeAccessLevelManager();
                }
            
                return $this->accessLevelManager;
            break;
            
            case '\\Zepi\\Core\\AccessControl\\Manager\\EventAccessManager':
                if ($this->eventAccessManager === null) {
                    $eventAccessObjectBackend = $this->framework->initiateObject('\Zepi\Turbo\Backend\FileObjectBackend', array(
                        'path' => $this->framework->getRootDirectory() . '/data/event-access-levels.data'
                    ));
            
                    $this->eventAccessManager = $this->framework->initiateObject($className, array(
                        'eventAccessObjectBackend' => $eventAccessObjectBackend
                    ));
                    $this->eventAccessManager->initializeEventAccessManager();
                }
            
                return $this->eventAccessManager;
            break;
            
            case '\\Zepi\\Core\\AccessControl\\DataSource\\AccessEntitiesDataSourceDoctrine':
                $dataSourceManager = $this->framework->getDataSourceManager();
                
                return $this->framework->initiateObject($className, array(
                    'permissionsDataSource' => $dataSourceManager->getDataSource('\\Zepi\\Core\\AccessControl\\DataSource\\PermissionsDataSourceInterface')
                ));
            break;
            
            default: 
                return $this->framework->initiateObject($className);
            break;
        }
    }