Exakat\Tasks\OnePage::run PHP Метод

run() публичный Метод

public run ( )
    public function run()
    {
        $progress = 0;
        $begin = microtime(true);
        $this->project_dir = $this->config->projects_root . '/projects/onepage/';
        // checking for installation
        if (!file_exists($this->project_dir)) {
            shell_exec($this->config->php . ' ' . $this->config->executable . ' init -p onepage ');
            mkdir($this->project_dir . '/code', 0755);
            shell_exec($this->config->php . ' ' . $this->config->executable . ' phploc -p onepage ');
        }
        $this->updateProgress($progress++);
        // todo : check that there is indeed this project or create it.
        if (!file_exists($this->config->filename)) {
            throw new NoSuchFile($this->config->filename);
        }
        // todo : check that there is indeed this project or create it.
        if (!is_file($this->config->filename) || !is_readable($this->config->filename)) {
            die("'{$this->config->filename}' must be a readable file. Aborting\n");
        }
        $this->cleanLogForProject('onepage');
        copy($this->config->filename, $this->config->projects_root . '/projects/onepage/code/onepage.php');
        $this->updateProgress($progress++);
        $this->logTime('Start');
        $datastorePath = $this->config->projects_root . '/projects/onepage/datastore.sqlite';
        if (file_exists($datastorePath)) {
            unlink($datastorePath);
        }
        unset($this->datastore);
        $this->datastore = new Datastore($this->config, Datastore::CREATE);
        $audit_start = time();
        $this->datastore->addRow('hash', array('audit_start' => $audit_start, 'exakat_version' => Exakat::VERSION, 'exakat_build' => Exakat::BUILD));
        display("Cleaning DB\n");
        $task = new CleanDb($this->gremlin, $this->config);
        $task->run();
        $this->updateProgress($progress++);
        $this->logTime('CleanDb');
        display("Running files\n");
        $task = new Files($this->gremlin, $this->config);
        $task->run();
        $this->updateProgress($progress++);
        $this->logTime('Files');
        display("Running project 'onepage'\n");
        $task = new Load($this->gremlin, $this->config);
        $task->run();
        display("Project loaded\n");
        $this->updateProgress($progress++);
        $this->logTime('Loading');
        $task = new Analyze($this->gremlin, $this->config);
        $task->run();
        rename($this->config->projects_root . '/projects/onepage/log/analyze.log', $this->config->projects_root . '/projects/onepage/log/analyze.onepage.log');
        display("Project analyzed\n");
        $this->updateProgress($progress++);
        $this->logTime('Analyze');
        $b1 = microtime(true);
        $task = new Dump($this->gremlin, $this->config);
        $task->run();
        display("Project dumped\n");
        $e1 = microtime(true);
        $task = new Report2($this->gremlin, $this->config);
        $task->run();
        display("Project reported\n");
        $this->logTime('Report');
        $this->updateProgress($progress++);
        display("Project reported\n");
        $this->updateProgress($progress++);
        // Clean code
        unlink($this->config->projects_root . '/projects/onepage/code/onepage.php');
        $audit_end = time();
        $this->datastore->addRow('hash', array('audit_end' => $audit_end, 'audit_length' => $audit_end - $audit_start));
        $this->logTime('Final');
        display("End 2\n");
        $end = microtime(true);
        $this->updateProgress($progress++);
        $this->logTime('Files');
        // Back to 0
        $this->updateProgress(0);
    }

Usage Example

Пример #1
0
 public function execute(Config $config)
 {
     switch ($config->command) {
         case 'doctor':
             $doctor = new Tasks\Doctor($this->gremlin, $this->config);
             $doctor->run($config);
             break;
         case 'init':
             $task = new Tasks\Initproject($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'anonymize':
             $task = new Tasks\Anonymize($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'files':
             $task = new Tasks\Files($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'load':
             $task = new Tasks\Load($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'stat':
             $task = new Tasks\Stat($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'analyze':
             $task = new Tasks\Analyze($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'results':
             $task = new Tasks\Results($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'export':
             $task = new Tasks\Export($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'report':
             $task = new Tasks\Report2($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'project':
             $task = new Tasks\Project($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'magicnumber':
             $task = new Tasks\Magicnumber($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'clean':
             $task = new Tasks\Clean($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'status':
             $task = new Tasks\Status($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'help':
             $task = new Tasks\Help($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'cleandb':
             $task = new Tasks\CleanDb($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'onepage':
             $task = new Tasks\OnePage($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'update':
             $task = new Tasks\Update($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'onepagereport':
             $task = new Tasks\OnepageReport($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'phploc':
             $task = new Tasks\Phploc($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'findextlib':
             $task = new Tasks\FindExternalLibraries($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'dump':
             $task = new Tasks\Dump($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'jobqueue':
             $task = new Tasks\Jobqueue($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'queue':
             $task = new Tasks\Queue($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'test':
             $task = new Tasks\Test($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'remove':
             $task = new Tasks\Remove($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'server':
             $task = new Tasks\Server($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'upgrade':
             $task = new Tasks\Upgrade($this->gremlin, $this->config);
             $task->run($config);
             break;
         case 'version':
         default:
             $version = self::VERSION;
             $build = self::BUILD;
             $date = date('r', filemtime(__FILE__));
             echo "\n ________                 __              _    \n|_   __  |               [  |  _         / |_  \n  | |_ \\_| _   __  ,--.   | | / ]  ,--. `| |-' \n  |  _| _ [ \\ [  ]`'_\\ :  | '' <  `'_\\ : | |   \n _| |__/ | > '  < // | |, | |`\\ \\ // | |,| |,  \n|________|[__]`\\_]\\'-;__/[__|  \\_]\\'-;__/\\__/  \n                                               \n\nExakat : @ 2014-2016 Damien Seguy. \nVersion : ", $version, ' - Build ', $build, ' - ', $date, "\n";
             break;
     }
 }