| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
require_once "phing/Task.php"; |
|---|
| 4 |
|
|---|
| 5 |
require_once "SchemaReader.php"; |
|---|
| 6 |
require_once "midcomDBAWriter.php"; |
|---|
| 7 |
require_once "midcom_schema_factory.php"; |
|---|
| 8 |
require_once 'configwriter.php'; |
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
class CreateCrud extends Task { |
|---|
| 12 |
|
|---|
| 13 |
function __construct() |
|---|
| 14 |
{ |
|---|
| 15 |
|
|---|
| 16 |
} |
|---|
| 17 |
|
|---|
| 18 |
protected $returnProperty; |
|---|
| 19 |
|
|---|
| 20 |
/** |
|---|
| 21 |
* The root path to where the module is stored. |
|---|
| 22 |
*/ |
|---|
| 23 |
private $root = null; |
|---|
| 24 |
|
|---|
| 25 |
* The target directory where the packagefile should be saved. |
|---|
| 26 |
*/ |
|---|
| 27 |
protected $target_dir = null; |
|---|
| 28 |
|
|---|
| 29 |
public function setRoot($str) |
|---|
| 30 |
{ |
|---|
| 31 |
$this->root = $str; |
|---|
| 32 |
} |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
public function setReturnProperty($r) |
|---|
| 36 |
{ |
|---|
| 37 |
$this->returnProperty = $r; |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
* The name of the midcom |
|---|
| 41 |
*/ |
|---|
| 42 |
protected $module; |
|---|
| 43 |
|
|---|
| 44 |
public function setModule ( $m ) { |
|---|
| 45 |
$this->module = $m; |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
* The classtype to make crud for |
|---|
| 49 |
*/ |
|---|
| 50 |
protected $type; |
|---|
| 51 |
|
|---|
| 52 |
public function setType ( $type ) { |
|---|
| 53 |
$this->type = $type; |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
* The schemafile to use |
|---|
| 58 |
*/ |
|---|
| 59 |
protected $schema; |
|---|
| 60 |
public function setSchema( $s ) |
|---|
| 61 |
{ |
|---|
| 62 |
$this->schema = $s; |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
public $moduleRoot ; |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
* The init method: Do init steps. |
|---|
| 70 |
*/ |
|---|
| 71 |
public function init() |
|---|
| 72 |
{ |
|---|
| 73 |
echo "Make CRUD - not war! \n" ; |
|---|
| 74 |
$this->moduleRoot = $this->root . "/" . $this->type; |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
* The main entry point method. |
|---|
| 78 |
*/ |
|---|
| 79 |
public function main() |
|---|
| 80 |
{ |
|---|
| 81 |
|
|---|
| 82 |
$this->moduleRoot = $this->root . "/" . $this->module; |
|---|
| 83 |
$schema = new SchemaReader( $this->schema, $this->type ); |
|---|
| 84 |
|
|---|
| 85 |
$midcomdba = new MidcomDBAWriter( $schema, $this->moduleRoot , $this->type ); |
|---|
| 86 |
$midcomdba->write(); |
|---|
| 87 |
|
|---|
| 88 |
$dmschema = new midcom_schema_factory( $schema, $this->moduleRoot,$this->type ); |
|---|
| 89 |
$dmschema->write( ); |
|---|
| 90 |
|
|---|
| 91 |
$configwriter = new configwriter( $this->moduleRoot ); |
|---|
| 92 |
$configwriter->content[$this->type . "_schemadb"] = "file://" . str_replace( '.', '_', $this->module ) . "/config/schemadb_" . $this->type . ".inc"; |
|---|
| 93 |
$configwriter->save( ); |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
} |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|