container = $container; } protected function getContainer() { return $this->container; } /** * Rebuild the system with metadata, database and cache clearing * * @return bool */ public function rebuild($entityList = null) { $result = $this->clearCache(); $result &= $this->rebuildMetadata(); $result &= $this->rebuildDatabase($entityList); return $result; } /** * Clear a cache * * @return bool */ public function clearCache() { $result = $this->getContainer()->get('fileManager')->removeInDir($this->cachePath); if ($result != true) { throw new Exceptions\Error("Error while clearing cache"); } $this->updateCacheTimestamp(); return $result; } /** * Rebuild database * * @return bool */ public function rebuildDatabase($entityList = null) { try { $result = $this->getContainer()->get('schema')->rebuild($entityList); } catch (\Exception $e) { $result = false; $GLOBALS['log']->error('Fault to rebuild database schema'.'. Details: '.$e->getMessage()); } if ($result != true) { throw new Exceptions\Error("Error while rebuilding database. See log file for details."); } $this->updateCacheTimestamp(); return $result; } /** * Rebuild metadata * * @return bool */ public function rebuildMetadata() { $metadata = $this->getContainer()->get('metadata'); $metadata->init(true); $ormMeta = $metadata->getOrmMetadata(true); $this->updateCacheTimestamp(); return empty($ormMeta) ? false : true; } /** * Update cache timestamp * * @return bool */ public function updateCacheTimestamp() { $this->getContainer()->get('config')->updateCacheTimestamp(); $this->getContainer()->get('config')->save(); return true; } }