Skip to content

Commit

Permalink
Merge pull request #28 from pedro151/V1.5.x
Browse files Browse the repository at this point in the history
V1.5.2
  • Loading branch information
pedro151 committed Jan 18, 2017
2 parents bf1ef21 + 1073c69 commit cd89f1b
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 47 deletions.
Binary file modified bin/orm-generator.phar
Binary file not shown.
22 changes: 22 additions & 0 deletions build/Classes/AdapterConfig/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ abstract class AbstractAdapter
'status' => false ,
// flags para criar todas as tabelas ou nao
'tables' => array () ,
// lista de Classes opcionais pre-definidas para serem criadas
'optional-classes'=> array (),
//Lista de tabelas a serem ignoradas
'ignoreTable' => array () ,
);
Expand Down Expand Up @@ -433,6 +435,26 @@ public function getListTablesName(){
return "'$str'";
}

/**
* @return bool
*/
public function hasOptionalClasses (){
return ! empty( $this->arrConfig[ 'optional-classes' ] );
}

/**
* @return string[]
*/
public function getOptionalClasses ()
{
if ( is_string ( $this->arrConfig[ 'optional-classes' ] ) )
{
return array ( $this->arrConfig[ 'optional-classes' ] );
}

return $this->arrConfig[ 'optional-classes' ];
}

/**
* @param $str
*
Expand Down
20 changes: 18 additions & 2 deletions build/Classes/AdapterConfig/ZendFrameworkOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
use Classes\AdapterMakerFile\ZendFrameworkOne\DbTable;
use Classes\AdapterMakerFile\ZendFrameworkOne\Entity;
use Classes\AdapterMakerFile\ZendFrameworkOne\Model;
use Classes\AdapterMakerFile\ZendFrameworkOne\Peer;

require_once "Classes/AdapterConfig/AbstractAdapter.php";
require_once "Classes/AdapterMakerFile/ZendFrameworkOne/DbTable.php";
require_once "Classes/AdapterMakerFile/ZendFrameworkOne/Entity.php";
require_once "Classes/AdapterMakerFile/ZendFrameworkOne/Model.php";
require_once "Classes/AdapterMakerFile/ZendFrameworkOne/Peer.php";

/**
* @author Pedro Alarcao <phacl151@gmail.com>
Expand Down Expand Up @@ -85,11 +87,25 @@ protected function parseFrameworkConfig ()
*/
public function getMakeFileInstances ()
{
return array (

$instances = array ();
if ( $this->hasOptionalClasses () )
{
foreach ( $this->getOptionalClasses () as $optionalClass )
{
$Name = ucfirst ( $optionalClass );
$className = "Classes\\AdapterMakerFile\\ZendFrameworkOne\\{$Name}";
if(method_exists($className,'getInstance')){
$instances[] = $className::getInstance ();
}
}
}

return array_merge ( array (
DbTable::getInstance () ,
Entity::getInstance () ,
Model::getInstance ()
);
) , $instances );
}

}
4 changes: 3 additions & 1 deletion build/Classes/AdapterMakerFile/ZendFrameworkOne/DbTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTab
);
$class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) );

$dependents[] = $class;
if(!in_array($class,$dependents)){
$dependents[] = $class;
}
}
}

Expand Down
28 changes: 28 additions & 0 deletions build/Classes/AdapterMakerFile/ZendFrameworkOne/Peer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Classes\AdapterMakerFile\ZendFrameworkOne;
use Classes\AdapterMakerFile\AbstractAdapter;

/**
* @author Pedro Alarcao <phacl151@gmail.com>
* @link https://github.com/pedro151/orm-generator
*/
class Peer extends AbstractAdapter
{
/**
* @var void
*/
public $pastName = 'Peer';
protected $fileTpl = "peer.php";
protected $fileFixedData = array (
'exception' => array (
'tpl' => "model_exception.php" ,
'name' => "Exception"
)
);

public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable )
{
return array();
}
}
31 changes: 16 additions & 15 deletions build/Classes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,22 @@ class Config
);

private $parameterList = array (
'init' => 'Creates the necessary configuration file to start using the orm-generator.' ,
'name-ini' => 'reference to another .ini file configuration (relative path).' ,
'config-env' => 'orm-generator configuration environment.' ,
'framework' => 'name framework used, which has the contents of the database configurations and framework template.' ,
'driver' => 'database driver name (Ex.: pgsql).' ,
'database' => 'database name.' ,
'schema' => 'database schema name (one or more than one).' ,
'tables' => 'table name (parameter can be used more then once).' ,
'clean-trash' => 'delete all files that do not belong to your Database due' ,
'status' => 'show status of implementation carried out after completing the process.' ,
'version' => 'shows the version of orm-generator.' ,
'help' => "help command explaining all the options and manner of use." ,
'path' => "specify where to create the files (default is current directory)." ,
'update' => "Upgrade to latest version.",
'download' => "download the reported version (ex. --download=1.5.0). "
'init' => 'Creates the necessary configuration file to start using the orm-generator.' ,
'name-ini' => 'reference to another .ini file configuration (relative path).' ,
'config-env' => 'orm-generator configuration environment.' ,
'framework' => 'name framework used, which has the contents of the database configurations and framework template.' ,
'driver' => 'database driver name (Ex.: pgsql).' ,
'database' => 'database name.' ,
'schema' => 'database schema name (one or more than one).' ,
'tables' => 'table name (parameter can be used more then once).' ,
'optional-classes' => 'List of optional Predefined classes to be created (Consult in github the list of each framework).' ,
'clean-trash' => 'delete all files that do not belong to your Database due' ,
'status' => 'show status of implementation carried out after completing the process.' ,
'version' => 'shows the version of orm-generator.' ,
'help' => "help command explaining all the options and manner of use." ,
'path' => "specify where to create the files (default is current directory)." ,
'update' => "Upgrade to latest version." ,
'download' => "download the reported version (ex. --download=1.5.0). "
);

public function __construct ( $argv , $basePath , $numArgs )
Expand Down
2 changes: 1 addition & 1 deletion build/Classes/Update/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Version
{
private static $_currentVersion = "1.5.1";
private static $_currentVersion = "1.5.2";

private static $lastVersion;

Expand Down
10 changes: 10 additions & 0 deletions build/Classes/templates/zf1/dbtable_abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ public function getTableSchema ()
return $this->_schema;
}

/**
* @param array $config
* @return Model_TableAbstract
*/
public static function getIntance($config = array())
{
$name = get_called_class();
return new $name( $config );
}

/**
* Retorna o numero de linhas na tabela com o parametro opcional WHERE
*
Expand Down
23 changes: 23 additions & 0 deletions build/Classes/templates/zf1/peer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?="<?php\n"?>

/**
* Application Model Peer
*
* <?=$this->config->last_modify."\n"?>
*
* Tabela definida por 'tablename'
*
* @package <?=$objTables->getNamespace()?><?="\n"?>
* @subpackage Peer
* @author <?=$this->config->author."\n"?>
*
* @copyright <?=$this->config->copyright."\n"?>
* @license <?=$this->config->license."\n"?>
* @link <?=$this->config->link."\n"?>
* @version <?=$this->config->version."\n"?>
*/

class <?=$objTables->getNamespace()?>_Peer_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$objTables->getNamespace()?$objTables->getNamespace()."_":''?>DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () ) . "\n"?>
{
/* @TODO Codifique aqui */
}
1 change: 1 addition & 0 deletions build/phar-generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
'schema:',
'driver:',
'tables:',
'optional-classes:',
'framework:',
'path:',
'clean-trash:',
Expand Down
75 changes: 47 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
{
"name": "pedro151/orm-generator",
"description": "orm-generator maps the entire database and then creates the DAO (Data Access Object) and ORM (Object-relational mapping) of the entire database to facilitate the development. uses various types of databases like Postgres and Mysql and various types of ORM framework.",
"keywords": ["orm", "datamapper", "database", "model", "mapper", "entity", "dao", "generator", "orm-generator", "mysql", "postgres", "phalcon", "zend"],
"license": "MIT",
"version": "v1.5.1",
"authors": [
{
"name": "pedro151",
"email": "phacl@hotmail.com"
}
],
"minimum-stability": "dev",
"autoload" : {
"psr-4" : {
"Classes\\" : "build/Classes"
}
},
"autoload-dev" : {
"psr-4" : {
"TestMysql\\" : "TestMysql",
"TestPgsql\\" : "TestPgsql"
}
},
"require" : {
"php" : ">=5.3.0"
},
"require-dev" : {
"phpunit/phpunit": "~4.5"
"name" : "pedro151/orm-generator",
"description" : "orm-generator maps the entire database and then creates the DAO (Data Access Object) and ORM (Object-relational mapping) of the entire database to facilitate the development. uses various types of databases like Postgres and Mysql and various types of ORM framework.",
"keywords" : [
"orm",
"datamapper",
"database",
"model",
"mapper",
"entity",
"dao",
"generator",
"orm-generator",
"mysql",
"postgres",
"phalcon",
"zend"
],
"license" : "MIT",
"version" : "v1.5.2",
"authors" : [
{
"name" : "pedro151",
"email" : "phacl@hotmail.com"
}
],
"minimum-stability" : "dev",
"autoload" : {
"psr-4" : {
"Classes\\" : "build/Classes"
}
},
"autoload-dev" : {
"psr-4" : {
"TestMysql\\" : "TestMysql",
"TestPgsql\\" : "TestPgsql"
}
},
"require" : {
"php" : ">=5.3.0"
},
"require-dev" : {
"phpunit/phpunit" : "~4.5"
},
"config" : {
"preferred-install" : "dist",
"disable-tls" : true,
"secure-http" : false
}
}
2 changes: 2 additions & 0 deletions configs/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ framework-path-library = ""

namespace = ''

optional-classes = 'peer'

;=============TODO==============
; table name (parameter can be used more then once)
;tables=""
Expand Down
1 change: 1 addition & 0 deletions generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
'schema:' ,
'driver:' ,
'tables:',
'optional-classes:',
'framework:' ,
'path:',
'clean-trash:',
Expand Down

0 comments on commit cd89f1b

Please sign in to comment.