initializes the database Object if necessary


@param string $engine

@throws \chilimatic\lib\exception\ViewException|\Exception
@return boolean
166688
protected function __init_view($engine = '')
    {

        $view = (string)__NAMESPACE__ . (string)(empty($engine) ? "\\View_{$this->default_view_engine}" : "\\View_{$engine}");

        if ($this->view instanceof $view) return true;

        try {
            $this->view = new $view();
        } catch (ViewException $e) {
            throw $e;
        }

        return true;
    }
536780
private function newAction($class, $engine)
    {
        if (!class_exists($engine)) {
            throw new StatusCode\BadRequestException('Could not resolve engine');
        }

        try {
            $action = $this->actionFactory->factory($class, $engine);
        } catch (FactoryResolveException $e) {
            throw new StatusCode\BadRequestException($e->getMessage());
        }

        if (!$action instanceof ActionInterface) {
            throw new StatusCode\BadRequestException('Could not resolve action');
        }

        return $action;
    }
110683
public function register($engine, Closure $resolver)
    {
        unset($this->resolved[$engine]);

        $this->resolvers[$engine] = $resolver;
    }
289598
public function initTable()
    {

        // If table not exist ,create the table
        $tableExist = $this->db->query("SHOW TABLES LIKE '{$this->table}'")->execute();

        if (!$tableExist) {
            $sql = "CREATE TABLE `$this->table` (
                            `{$this->idCol}` VARBINARY(128) NOT NULL PRIMARY KEY,
                            `{$this->dataCol}` BLOB NOT NULL,
                            `{$this->lifetimeCol}` MEDIUMINT NOT NULL,
                            `{$this->timeCol}` INTEGER UNSIGNED NOT NULL
                            ) COLLATE utf8_bin, ENGINE = InnoDB;";

            $result = $this->db->query($sql)->execute();

            $tableExist = $this->db->query("SHOW TABLES LIKE '{$this->table}'")->execute();

            // Check table creation result, if not throw error
            if (!$tableExist) {
                throw new Exception('Fail to create database session table');
            }
        }
    }
831922
public function setEngine($engine)
	{
		// if param given as an object
		if ($engine instanceof Dwoo) {
			$this->_engine = $engine;
		}
		//
		elseif (is_subclass_of($engine, 'Dwoo') || 'Dwoo' === $engine) {
			$this->_engine = new $engine();
		}
		else {
			throw new Dwoo_Exception("Custom engine must be a subclass of Dwoo");
		}
	}
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;
    }
139368
public function setEngine($name): bool
    {
        $this->loadTemplateEngines();
        if (isset($this->engines[$name])) {
            $this->current_engine = $this->engines[$name];
            Logger::log('Set the Template Engine to '.$name);

            return true;
        }
        throw new LayoutException('Could not set engine. Engine does not exist', 1);
    }
606542
private function init()
    {
        $nb_engine = CNabuEngine::getEngine();

        $session_name = session_name();
        $nb_engine->traceLog("Session Name", $session_name);
        if (array_key_exists($session_name, $_GET)) {
            $sessid = filter_input(INPUT_GET, $session_name);
            if (preg_match('/^[a-zA-Z0-9]{26}$/', $sessid)) {
                session_id($sessid);
                $nb_engine->traceLog("Session source", "GET");
            } else {
                $nb_engine->traceLog("Session source", "COOKIE");
            }
        } else {
            $nb_engine->traceLog("Session source", "COOKIE");
        }
    }
389969
private function init($image)
    {
        /** @var ConfigModel $settings */
        $settings = ImagerService::getConfig();

        if (\is_string($image)) {
            if (strncmp($image, $settings->imagerUrl, \strlen($settings->imagerUrl)) === 0) {
                // Url to a file that is in the imager library
                $this->getPathsForLocalImagerFile($image);
            } else {
                if (strncmp($image, '//', 2) === 0) {
                    // Protocol relative url, add https
                    $image = 'https:'.$image;
                }

                if (strncmp($image, 'http', 4) === 0 || strncmp($image, 'https', 5) === 0) {
                    // External url
                    $this->type = 'remoteurl';
                    $this->getPathsForUrl($image);
                } else {
                    // Relative path, assume that it's relative to document root
                    $this->getPathsForLocalFile($image);
                }
            }
        } else {
            // It's some kind of model
            if (\get_class($image) === 'aelvan\\imager\\models\\CraftTransformedImageModel') {
                $this->getPathsForLocalImagerFile($image->url);
            } else {
                if ($image instanceof Asset) {
                    $this->asset = $image;

                    // todo : Improve this check to take into account other volumes that are local?
                    try {
                        $volumeClass = \get_class($image->getVolume());
                    } catch (InvalidConfigException $e) {
                        Craft::error($e->getMessage(), __METHOD__);
                        throw new ImagerException($e->getMessage(), $e->getCode(), $e);
                    }

                    if ($volumeClass === 'craft\volumes\Local') {
                        $this->getPathsForLocalAsset($image);
                    } else {
                        $this->type = 'volume';
                        $this->getPathsForVolumeAsset($image);
                    }
                } else {
                    throw new ImagerException(Craft::t('imager', 'An unknown image object was used.'));
                }
            }
        }
    }
376855
@Override
    public final void prepare(Engine engine) throws InitializationException {
        if (isEnabled()) {
            prepareAnalyzer(engine);
        } else {
            LOGGER.debug("{} has been disabled", getName());
        }
    }
484170
protected function init($flags = TemplateEngine::NO_ERRORS)
    {
        Config::load('Assets\Composer\TemplateEngineConfig');
        $this->setFlags($flags);
        $this->template = new Template;
        $this->view = new View;
        $this->registry = new Registry;
        $this->setPageLayout(self::$default_page_layout);
    }
1194409
function setPreferredEngine($engine)
    {
        if ($this->mode_3cbc) {
            $this->des[0]->setPreferredEngine($engine);
            $this->des[1]->setPreferredEngine($engine);
            $this->des[2]->setPreferredEngine($engine);
        }

        return parent::setPreferredEngine($engine);
    }
1177344
private function initialize($request = null)
    {
        // Store a reference to the database object
        // so the database connection can be reused during tests
        $this->oldDb = null;
        if (isset($this->app['db']) && $this->app['db']->connection()) {
            $this->oldDb = $this->app['db'];
        }

        if (class_exists(Facade::class)) {
            // If the container has been instantiated ever,
            // we need to clear its static fields before create new container.
            Facade::clearResolvedInstances();
        }

        $this->app = $this->kernel = require $this->module->config['bootstrap_file'];
        
        // in version 5.6.*, lumen introduced the same design pattern like Laravel
        // to load all service provider we need to call on Laravel\Lumen\Application::boot()
        if (method_exists($this->app, 'boot')) {
            $this->app->boot();
        }
        // Lumen registers necessary bindings on demand when calling $app->make(),
        // so here we force the request binding before registering our own request object,
        // otherwise Lumen will overwrite our request object.
        $this->app->make('request');

        $request = $request ?: SymfonyRequest::create($this->module->config['url']);
        $this->app->instance('Illuminate\Http\Request', Request::createFromBase($request));

        // Reset the old database if there is one
        if ($this->oldDb) {
            $this->app->singleton('db', function () {
                return $this->oldDb;
            });
            Model::setConnectionResolver($this->oldDb);
        }

        $this->module->setApplication($this->app);
    }
689802
public function initialize()
    {
        parent::initialize();

        $this->eventsManager->attach('view:notFoundView', function ($event, \Phalcon\Mvc\ViewInterface $view) {
            if (!in_array($this->dispatcher->getActionName(), ['new', 'edit', 'show', 'index'])) {
                return false;
            }

            if ($view->getCurrentRenderLevel() == View::LEVEL_ACTION_VIEW) {
                $templatePath = implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'Crud','']);

                $view->setViewsDir($templatePath);
                $view->setControllerViewPath('views');
                $view->setRenderLevel(View::LEVEL_ACTION_VIEW);

                $view->render('', $this->dispatcher->getActionName());
            }
        });
    }
176436
public function init($config = [])
    {

        if (isset($config['session_cache'])) {
            $session_type = $config['session_cache'];
        } else {
            $session_type = $config['cache_type'];
        }

        /**
         * initialize the current Cache
         */
        $param              = new \stdClass();
        $param->type        = (string)$session_type;
        $param->credentials = (($s = Config::get('session_cache_settings') == '') ? Config::get('cache_settings') : $s);
        // write it to the cache
        $this->engine = CacheManager::getInstance($param);

        if (!$this->engine || !$this->engine->isConnected()) return false;

        return true;
    }
10522
private function initDataSource()
	{
        $className = $this->conf['db']['engine'];
		if (class_exists($className))
		{
			$this->db = new $className;
			$this->db->init($this->conf['db']['host'], $this->conf['db']['user'],
				$this->conf['db']['password'], $this->conf['db']['name'],
                $this->conf['db']['prefix']);
		}
		else
		{
            throw new Eresus_Exception_ComponentCorrupted(
                sprintf('Library "%s" not found!', $this->conf['db']['engine']));
		}
	}
1138915
protected function prepareEngine(EngineInterface $engine)
    {
        if ($engine instanceof ViewAwareInterface && $this !== $engine->getManager()) {
            $engine->setManager($this);
        }

        return $engine;
    }