示例#1
0
 /**
  * Synchronize application data (packages metadata and database packages rows).
  *
  * @return void
  */
 public function syncAction()
 {
     try {
         /**
          * Add missing packages.
          * Read packages files and find packages that is missing in db.
          *
          * $modulesWidgets - array of widgets that is located in modules [module => [widgets...n]].
          * $notFoundWidgets - array of widgets as external packages [widgets...n].
          * $packages - all packages names found at metadata files.
          * $widgets - all widgets names found at metadata files.
          */
         list($modulesWidgets, $notFoundWidgets, $packages, $widgets) = $this->_checkMissingPackages();
         /**
          * Add missing widgets from modules and from packages.
          */
         $this->_checkMissingWidgets($modulesWidgets, $notFoundWidgets);
         /**
          * Remove unused packages.
          */
         $this->_removeUnusedPackages($packages);
         /**
          * Remove unused widgets.
          */
         $this->_removeUnusedWidgets($widgets);
         /**
          * Generate metadata.
          */
         $manager = new Manager(Package::find(), $this->getDI());
         $manager->generateMetadata(null, true);
         print ConsoleUtil::success('Application successfully synchronized.') . PHP_EOL;
     } catch (Exception $e) {
         print ConsoleUtil::error($e->getMessage()) . PHP_EOL;
     }
 }
示例#2
0
文件: Create.php 项目: biggtfish/cms
 /**
  * Validates the form.
  *
  * @param array $data               Data to validate.
  * @param bool  $skipEntityCreation Skip entity creation.
  *
  * @return boolean
  */
 public function isValid($data = null, $skipEntityCreation = true)
 {
     if (!$data) {
         $data = $this->getDI()->getRequest()->getPost();
     }
     // Check package location.
     $packageManager = new Manager();
     $path = $packageManager->getPackageLocation($data['type']);
     if (!is_writable($path)) {
         $this->addError('Can not create package. Package location isn\'t writable: ' . $path);
         $this->setValues($data);
         return false;
     }
     // Also check that config file is writable.
     if (!is_writable(ROOT_PATH . Config::CONFIG_PATH)) {
         $this->addError('Configuration file isn\'t writable...');
         $this->setValues($data);
         return false;
     }
     if (isset($data['type']) && $data['type'] == 'widget' && !$this->hasEntity('widget')) {
         $this->addEntity(new WidgetModel(), 'widget');
     }
     if (!parent::isValid($data, $skipEntityCreation)) {
         return false;
     }
     // Check package existence.
     $id = $this->getEntity()->id;
     $condition = "type='{$data['type']}' AND name='{$data['name']}'" . ($id ? " AND id!='{$id}'" : '');
     if (Package::findFirst($condition)) {
         $this->addError('Package with that name already exist!');
         return false;
     }
     // Check widget existence.
     if ($this->hasEntity('widget')) {
         $name = ucfirst($data['name']);
         $id = $this->getEntity('widget')->id;
         $condition = "module='{$data['module']}' AND name='{$name}'" . ($id ? " AND id!='{$id}'" : '');
         if (WidgetModel::findFirst($condition)) {
             $this->addError('Widget with that name already exist!');
             return false;
         }
     }
     return true;
 }
示例#3
0
 /**
  * Save finish form action.
  *
  * @return ResponseInterface
  *
  * @Route("/save", methods={"GET"}, name="install-save")
  */
 public function saveAction()
 {
     if (!$this->_isPassed('finishAction')) {
         return $this->_selectAction();
     }
     foreach ($this->_actions as $action) {
         $this->_setPassed($action, false);
     }
     $this->_setupDatabase();
     $this->config->offsetSet('installed', true);
     $packageManager = new PackageManager(Package::find());
     $packageManager->generateMetadata();
     $assetsManager = new AssetManager($this->getDI(), false);
     $assetsManager->clear(true, PUBLIC_PATH . '/themes/' . Settings::getSetting('system_theme'));
     return $this->response->redirect();
 }
示例#4
0
 /**
  * Update packages metadata.
  *
  * @return void
  */
 protected function _updateMetadata()
 {
     $packageManager = new Manager();
     $packageManager->generateMetadata(Package::find());
 }