public function init($force = false)
    {
        $flockFactory = new Factory(new FlockStore());

        $lock = $flockFactory->createLock('propel-cache-generation');

        // Acquire a blocking cache generation lock
        $lock->acquire(true);

        try {
            if ($force) {
                (new Filesystem())->remove($this->getPropelCacheDir());
            }

            if (!file_exists($this->getTheliaDatabaseConfigFile())) {
                return false;
            }

            $this->buildPropelConfig();

            $this->buildPropelInitFile();
            require $this->getPropelInitFile();

            $theliaDatabaseConnection = Propel::getConnection('thelia');
            $this->schemaLocator->setTheliaDatabaseConnection($theliaDatabaseConnection);

            $this->buildPropelGlobalSchema();

            $this->buildPropelModels();
            $this->registerPropelModelLoader();

            $theliaDatabaseConnection->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);

            if ($this->debug) {
                // In debug mode, we have to initialize Tlog at this point, as this class uses Propel
                Tlog::getInstance()->setLevel(Tlog::DEBUG);

                Propel::getServiceContainer()->setLogger('defaultLogger', Tlog::getInstance());
                $theliaDatabaseConnection->useDebug(true);
            }
        } catch (\Throwable $th) {
            $fs = new Filesystem();
            $fs->remove(THELIA_CACHE_DIR . $this->environment);
            $fs->remove($this->getPropelModelDir());
            throw $th;
        } finally {
            // Release cache generation lock
            $lock->release();
        }

        return true;
    }
public function init($force = false)
    {
        $flockFactory = new Factory(new FlockStore());

        $lock = $flockFactory->createLock('propel-cache-generation');

        // Acquire a blocking cache generation lock
        $lock->acquire(true);

        try {
            if ($force) {
                (new Filesystem())->remove($this->getPropelCacheDir());
            }

            if (!file_exists($this->getTheliaDatabaseConfigFile())) {
                return false;
            }

            $this->buildPropelConfig();

            $this->buildPropelInitFile();
            require $this->getPropelInitFile();

            $theliaDatabaseConnection = Propel::getConnection('thelia');
            $this->schemaLocator->setTheliaDatabaseConnection($theliaDatabaseConnection);

            $this->buildPropelGlobalSchema();

            $this->buildPropelModels();
            $this->registerPropelModelLoader();

            $theliaDatabaseConnection->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);

            if ($this->debug) {
                // In debug mode, we have to initialize Tlog at this point, as this class uses Propel
                Tlog::getInstance()->setLevel(Tlog::DEBUG);

                Propel::getServiceContainer()->setLogger('defaultLogger', Tlog::getInstance());
                $theliaDatabaseConnection->useDebug(true);
            }
        } catch (\Throwable $th) {
            $fs = new Filesystem();
            $fs->remove(THELIA_CACHE_DIR . $this->environment);
            $fs->remove($this->getPropelModelDir());
            throw $th;
        } finally {
            // Release cache generation lock
            $lock->release();
        }

        return true;
    }
public function init ( $ force = false ) { $ flockFactory = new Factory ( new FlockStore ( ) ) ; $ lock = $ flockFactory -> createLock ( 'propel-cache-generation' ) ; // Acquire a blocking cache generation lock $ lock -> acquire ( true ) ; try { if ( $ force ) { ( new Filesystem ( ) ) -> remove ( $ this -> getPropelCacheDir ( ) ) ; } if ( ! file_exists ( $ this -> getTheliaDatabaseConfigFile ( ) ) ) { return false ; } $ this -> buildPropelConfig ( ) ; $ this -> buildPropelInitFile ( ) ; require $ this -> getPropelInitFile ( ) ; $ theliaDatabaseConnection = Propel :: getConnection ( 'thelia' ) ; $ this -> schemaLocator -> setTheliaDatabaseConnection ( $ theliaDatabaseConnection ) ; $ this -> buildPropelGlobalSchema ( ) ; $ this -> buildPropelModels ( ) ; $ this -> registerPropelModelLoader ( ) ; $ theliaDatabaseConnection -> setAttribute ( ConnectionWrapper :: PROPEL_ATTR_CACHE_PREPARES , true ) ; if ( $ this -> debug ) { // In debug mode, we have to initialize Tlog at this point, as this class uses Propel Tlog :: getInstance ( ) -> setLevel ( Tlog :: DEBUG ) ; Propel :: getServiceContainer ( ) -> setLogger ( 'defaultLogger' , Tlog :: getInstance ( ) ) ; $ theliaDatabaseConnection -> useDebug ( true ) ; } } catch ( \ Throwable $ th ) { $ fs = new Filesystem ( ) ; $ fs -> remove ( THELIA_CACHE_DIR . $ this -> environment ) ; $ fs -> remove ( $ this -> getPropelModelDir ( ) ) ; throw $ th ; } finally { // Release cache generation lock $ lock -> release ( ) ; } return true ; }
Initialize the Propel environment and connection.
@return bool Whether a Propel connection is available.
@param bool $force force cache generation
@throws \Throwable
Initialize the Propel environment and connection .