/**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $config = null;
     if (!empty($options['rules'])) {
         $config = IntegrityConfig\Config::create();
         foreach (explode(',', $options['rules']) as $rule_name) {
             $config->add(IntegrityConfig\Crumb::create($rule_name));
         }
     }
     $integrity = Integrity\Integrity::create()->check($config);
     if ($integrity->isImpaired()) {
         throw new sfCommandException($integrity->render(Integrity\Renderer\Helper::TYPE_TEXT));
     }
     $this->logSection('done', 'Project integrity is not impaired');
 }
Ejemplo n.º 2
0
 /**
  * Execute models command
  *
  * @param sfWebRequest $request 
  * @return string -json
  * @author Sergey Startsev
  */
 public function executeModels(sfWebRequest $request)
 {
     $command = $request->getParameter('cmd', $request->getParameter('xaction'));
     $params = $request->getParameterHolder()->getAll();
     $files = $request->getFiles();
     if (!empty($files) && array_key_exists('file', $files)) {
         $params["name"] = $files["file"]["name"];
         $params["tmp"] = $files["file"]["tmp_name"];
         $params["code"] = $files["file"]["error"];
     }
     $response = afStudioCommand::process('model', $command, $params);
     if ($command == 'get') {
         if ($response->getParameter(afResponseSuccessDecorator::IDENTIFICATOR)) {
             return $this->renderJson($response->getParameter(afResponseDataDecorator::IDENTIFICATOR_DATA));
         }
     }
     if ($command == 'export') {
         if ($response->getParameter(afResponseSuccessDecorator::IDENTIFICATOR)) {
             $data = $response->getParameter(afResponseDataDecorator::IDENTIFICATOR_DATA);
             $file_path = $data;
             $file_name = pathinfo($file_path, PATHINFO_BASENAME);
             $response = $this->getContext()->getResponse();
             $response->clearHttpHeaders();
             $response->addCacheControlHttpHeader('Cache-control', 'must-revalidate, post-check=0, pre-check=0');
             $response->setContentType('application/octet-stream', true);
             $response->setHttpHeader('Content-Transfer-Encoding', 'binary', true);
             $response->setHttpHeader('Content-Disposition', "attachment; filename={$file_name}", true);
             $response->sendHttpHeaders();
             readfile("{$file_path}");
             return sfView::NONE;
         }
     }
     if ($command == 'import') {
         return $this->renderText($response->asJson());
     }
     if (sfConfig::get('app_afs_check_integrity', true)) {
         $integrity = Integrity::create()->check(IntegrityConfig\Config::create()->add(IntegrityConfig\Crumb::create('Model')));
         if ($integrity->isImpaired()) {
             $response->integrity($integrity->render());
         }
     }
     return $this->renderJson($response->asArray());
 }