fix up cli
[Pman.Core] / RunGenerator.php
1 <?php
2
3 /**
4  * 
5  * this is technically a cli wrapper for the generator..
6  * 
7  * we will test it on the web initially..
8  * 
9  * 
10  */
11 require_once 'Pman.php';
12 class Pman_Core_RunGenerator extends Pman
13 {     
14     static $cli_desc = "Generate DataObjects (runs updatedatabase first)  
15                      does not change files, just shows you want would happen";
16         
17         
18     static $cli_opts = array(
19         'module' => array(
20             'desc' => 'Module (if new tables are found, they will be put in the modules database directory',
21             'short' => 'm',
22             'default' => '',
23             'min' => 1,
24             'max' => 1,
25             
26         ),
27         'overwrite' => array(
28             'desc' => 'Files to Overwrite (use _all_ to create everything)',
29             'default' => '',
30             'short' => 'o',
31             'min' => 1,
32             'max' => -1,
33             
34         )
35         
36     );
37     
38     var $cli = false;
39     function getAuth() {
40         
41         
42         $ff = HTML_FlexyFramework::get();
43         if (!empty($ff->cli)) {
44             $this->cli = true;
45             return true;
46         }
47         
48         parent::getAuth(); // load company!
49         $au = $this->getAuthUser();
50         if (!$au || $au->company()->comptype != 'OWNER') {
51             $this->jerr("Not authenticated", array('authFailure' => true));
52         }
53         $this->authUser = $au;
54         return true;
55     }
56      
57     function get($args, $opts)
58     {
59         //print_r($opts);exit;
60         
61         HTML_FlexyFramework::run('Core/UpdateDatabase');
62         
63          
64         
65         require_once 'Pman/Core/Generator.php';
66         ini_set('pcre.backtrack_limit', 2000000);
67         ini_set('pcre.recursion_limit', 2000000);
68         $this->init();
69         
70         $x = new Pman_Core_Generator();
71        // $x->page = clone($this);
72        
73         
74         $modules = $opts['module'];
75         // overwrite can be multiple
76         $overwrite = is_string($opts['overwrite']) ? array($opts['overwrite']) : $opts['overwrite'];
77
78         $x->start($this->cli, $modules, $overwrite);
79         
80         // technically it would be good to trash the cached ini files here.. 
81         // however we can not really do that, as the ownships are off..
82         //we can however regen our own files..
83         HTML_FlexyFramework::get()->generateDataobjectsCache(true);
84         
85         die("done!");
86     }
87     
88 }