Load engine service.

@param EngineTypeInterface $engine
The engine object.
@param string $type
The service type.
@param string|null $name
The service machine name.

@return \Droath\ProjectX\Engine\ServiceInterface
352717
public static function loadService(
        EngineTypeInterface $engine,
        $type,
        $name = null
    ) {
        $classname = static::serviceClassname($type);

        if (!class_exists($classname)) {
            throw new \RuntimeException(
                sprintf("Service class %s doesn't exist.", $classname)
            );
        }

        return new $classname($engine, $name);
    }
716176
protected static function getEngine($name)
    {
        if (!isset(self::$engines[$name])) {
            if ($name !== 'default') {
                return false;
            }
            self::registerEngine($name, new PhpConfig());
        }

        return self::$engines[$name];
    }
35565
protected function resolve($type, $name, $registry, array $args = array())
    {
        if($registry instanceof \Closure)
            return call_user_func_array($registry->bindTo($this), $args);

        if(is_string($registry)) {
            if($type == 'service')
                return $this->instantiate($registry);
            else
                return $this->instantiate($registry, $args);
        }

        // assume index 0 as class name
        if(is_array($registry))
        {
            $class = $registry[0];

            $arguments = array();

            // argument passed
            if(isset($registry[1]))
            {
                // the second element isn't an array
                if(!is_array($registry[1]))
                    throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Second value for array based ['.$name.'] registry must be an array');

                foreach($registry[1] as $arg)
                {
                    // if isn't string. allow only string.
                    if(!is_string($arg))
                        throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Argument for array based ['.$name.'] registry must be string');

                    if($arg = $this->tokenResolve($arg))
                        $arguments[] = $arg;
                }
            }

            // merge with the one passed
            $arguments = array_merge($arguments, $args);

            return $this->instantiate($class, $arguments);
        }

        throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Unable to resolve the ['.$name.'] registry');
    }
559293
public function load($resource, $type = null){
		$resolver = $this->getResolverForResource($resource, $type);
		if(is_string($resource) && $resource[0] === '/'){
			$resource = basename($resource);
		}
		$loader = $resolver->resolve($resource, $type);
		if($loader === false){
			throw new FileLoaderLoadException($resource);
		}
		return $loader->load($resource, $type);
	}
249570
public function engine($engine = null) {
		$db = $this->_getConnection();
		$config = $db->config();
		$database = $config['database'];
		$prefix = ''; //$config['prefix'];
		$engines = ['InnoDB', 'MyISAM'];

		while (!$engine) {
			$engine = $this->in('Please select target engine', $engines);
		}
		if (!in_array($engine, $engines)) {
			$this->abort('Please provide a valid target format/engine.');
		}

		$script = <<<SQL
SELECT  CONCAT('ALTER TABLE `', table_name, '` ENGINE=$engine;') AS statement
FROM    information_schema.tables AS tb
WHERE   table_schema = '$database'
AND     table_name LIKE '$prefix%'
AND     `ENGINE` != '$engine'
AND     `TABLE_TYPE` = 'BASE TABLE';
SQL;
		/** @var \Cake\Database\Statement\StatementDecorator $res */
		$res = $db->query($script);
		if (!$res) {
			$this->abort('Nothing to do...');
		}

		$script = '';
		foreach ($res as $r) {
			$this->out($r['statement'], 1, Shell::VERBOSE);
			$script .= $r['statement'];
		}

		if (!$this->param('dry-run')) {
			$continue = $this->in(count($res) . ' tables will be altered.', ['Y', 'N'], 'N');
			if (strtoupper($continue) !== 'Y') {
				$this->abort('Aborted!');
			}
		}

		if (!$this->params['dry-run']) {
			$db->query($script);
		} else {
			$this->out($script);
		}
		$this->out('Done :)');
	}
127363
protected function solve($type, $name, array $args = array())
    {
        if(!$this->services[$type]->has($name))
        {
            if($this->app[$type]->has('@'.$name))
            {
                return $this->app->dependencyCall($type, $name, $args);
            }
            else
            {
                $isShared = false;

                if($type == 'callable' && ($this->app['service']->has($name) || $isShared = $this->app['service']->has('@'.$name)))
                {
                    $service = $this->app->get($isShared ? '@'.$name : $name);

                    $this->invokables[$name] = $service;

                    if(is_callable($service))
                        return call_user_func_array($service, $args);
                }

                throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Unable to find ['.$name.'] in the registered '.$type);
            }
        }
        else
        {
            $registry = $this->services[$type]->get($name);
        }

        return $this->filter($type, $name, $this->resolve($type, $name, $registry, $args));
    }
1172274
public static <X> ServiceTypeLoader<X> load(Class<X> serviceType) {
        return load(serviceType, Thread.currentThread().getContextClassLoader());
    }
1224252
public static function getEngineType()
    {
        $container = self::getContainer();
        $builder = CollectionBuilder::create($container, new EngineTasks());

        return $container->get('projectXEngine')
            ->setBuilder($builder);
    }
1344524
public function load(string $key, string $useragent = ''): EngineInterface
    {
        if (!$this->initData->hasItem($key)) {
            throw new NotFoundException('the engine with key "' . $key . '" was not found');
        }

        $engineData = $this->initData->getItem($key);

        if (null === $engineData) {
            throw new NotFoundException('the engine with key "' . $key . '" was not found');
        }

        return (new EngineFactory($this->companyLoader, new VersionFactory()))->fromArray($this->logger, (array) $engineData, $useragent);
    }
638229
public function setEngine($engine)
    {
        if (!$this->engine instanceof Edge) {
            throw new \InvalidArgumentException('Engine should be instance of Edge');
        }

        $this->engine = $engine;

        return $this;
    }
1010397
public function load(ConnectionInterface $connection = null)
    {
        static::$connection = $connection;
        $this->loadComponents();
        $this->loadRegistry();
        $this->registerModelChecks();
        $this->componentsReady();
    }
21329
public function changeEngine($engine)
    {
        $allowed_engines = array(
            self::ENGINE_INNODB,
            self::ENGINE_MYISAM
        );
        
        if (!in_array($engine, $allowed_engines))
        {
            throw new \Exception('Unrecognized engine: ' . $engine);
        }
        
        $query = 
            "ALTER TABLE `" . $this->m_name . "` " .
            "ENGINE=" . $engine;
        
        $result = $this->m_mysqliConn->query($query);
        return $result;
    }
933190
protected function setEngineServiceOptions()
    {
        $project = ProjectX::getProjectType();

        if ($project instanceof EngineServiceInterface) {
            $engine = ProjectX::getEngineType();

            $classname = get_class($engine);
            $this->options[$classname::getTypeId()] = [
                'services' => $project->defaultServices()
            ];
        }

        return $this;
    }
637724
static function getEngine($template)
    {
        foreach (self::$engines as $pattern => $engine){
            if (fnmatch($pattern, $template)){
                if (is_string($engine)){
                    self::$engines[$pattern] = new $engine();
                }
                return self::$engines[$pattern];
            }
        }
        return null;
    }
804707
public Service getService(String type, String name) {
        for (int i = 0; i < configs.length; i++) {
            Provider p = getProvider(i);
            Service s = p.getService(type, name);
            if (s != null) {
                return s;
            }
        }
        return null;
    }
1237540
public static function Engine()
    {
        if (class_exists('Administration', false)) {
            return Administration::instance();
        } elseif (class_exists('Frontend', false)) {
            return Frontend::instance();
        } else {
            throw new Exception(__('No suitable engine object found'));
        }
    }
818473
function load_engine()
    {
        if ($this->engine) {
            return $this->engine;
        }

        // load config/localization
        $this->load_env();

        return $this->engine = new enigma_engine($this);
    }