Adição de renderização de classe representativas de tabela para banco de dados. Estrutura de armazenamento no aplicativo conforme padrão Zend Framework. Criação de classe construtora e de fonte de renderização. Chamada construtora da tabela no módulo Mimoza.
Esse commit está contido em:
@@ -155,6 +155,8 @@ class Mimoza extends Module implements Module_Interface
|
||||
$name = ucfirst(strtolower($entity->name));
|
||||
$controller = $this->getProject()->buildController($entity);
|
||||
$this->getFramework()->mkFile("project/application/controllers/{$name}Controller.php", $controller);
|
||||
$dbtable = $this->getProject()->buildDbTable($entity);
|
||||
$this->getFramework()->mkFile("project/application/models/{$name}.php", $dbtable);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
Mimoza_Loader::loadClass('Mimoza_Builder');
|
||||
|
||||
/**
|
||||
*
|
||||
* Construtor de Controladoras do Sistema
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
Mimoza_Loader::loadClass('Mimoza_Builder');
|
||||
|
||||
/**
|
||||
*
|
||||
* Classe Representativa de Tabelas de Banco de Dados
|
||||
* @author Wanderson Henrique Camargo Rosa
|
||||
*
|
||||
*/
|
||||
class Builder_DbTable extends Mimoza_Builder
|
||||
{
|
||||
public function build($element)
|
||||
{
|
||||
$this->author = $this->getProject()->getMindProject()->owner;
|
||||
$this->name = $element->name;
|
||||
$this->entity = ucfirst($element->name);
|
||||
|
||||
$primaries = array();
|
||||
foreach ($element->attributes as $attribute) {
|
||||
if ($attribute->pk) {
|
||||
$primaries[] = $attribute->name;
|
||||
}
|
||||
}
|
||||
$this->primaries = $primaries;
|
||||
|
||||
$dependencies = array();
|
||||
foreach ($element->refered as $refered) {
|
||||
$dependencies[] = ucfirst(substr($refered, strlen($this->name) + 1));
|
||||
}
|
||||
$this->dependencies = $dependencies;
|
||||
|
||||
$map = array();
|
||||
foreach ($element->foreignKeys as $key) {
|
||||
$table = array_pop($key);
|
||||
$map[$table] = array_pop($key);
|
||||
}
|
||||
$this->map = $map;
|
||||
|
||||
return $this->render('dbtable.phtml');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
[php]
|
||||
|
||||
/**
|
||||
* Controladora de <?php echo $this->name ?>
|
||||
* Mind Module for Zend Framework Applications (Mimoza)
|
||||
* @author <?php echo $this->author ?>
|
||||
* @see http://code.google.com/p/webmind/Mimoza
|
||||
* @package Application
|
||||
* @subpackage Controller
|
||||
*/
|
||||
class Application_Model_DbTable_<?php echo $this->entity ?> extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = '<?php echo $this->name ?>';
|
||||
protected $_primary = array(
|
||||
<?php foreach ($this->primaries as $primary) : ?>
|
||||
'<?php echo $primary ?>',
|
||||
<?php endforeach ?>
|
||||
);
|
||||
|
||||
protected $_dependentTables = array(
|
||||
<?php foreach ($this->dependencies as $dependency) : ?>
|
||||
'Model_DbTable_<?php echo $dependency ?>',
|
||||
<?php endforeach ?>
|
||||
);
|
||||
|
||||
protected $_referenceMap = array(
|
||||
<?php foreach ($this->map as $table => $reference) : ?>
|
||||
'<?php echo ucfirst($table) ?>' => array(
|
||||
'refTableClass' => 'Application_Model_DbTable_<?php echo ucfirst($table) ?>',
|
||||
'refColumns' => array('pk_<?php echo $table ?>'),
|
||||
'columns' => array('<?php echo $reference ?>'),
|
||||
),
|
||||
<?php endforeach ?>
|
||||
);
|
||||
}
|
||||
Referência em uma Nova Issue
Bloquear um usuário