Skip to content

Commit

Permalink
Merge branch 'v1.3.x'
Browse files Browse the repository at this point in the history
Conflicts:
	bin/orm-generator.phar
	build/Classes/AdapterMakerFile/ZendFrameworkOne/Entity.php
  • Loading branch information
pedro151 committed May 9, 2016
2 parents 6602608 + 5e486f1 commit e1c224e
Show file tree
Hide file tree
Showing 37 changed files with 543 additions and 199 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ORM-Generator
# orm-generator

[![Travis build status](https://api.travis-ci.org/pedro151/orm-generator.svg?branch=master)](https://travis-ci.org/pedro151/orm-generator)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/pedro151/orm-generator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/pedro151/orm-generator/?branch=master)
Expand All @@ -7,7 +7,7 @@
[![Latest Unstable Version](https://poser.pugx.org/pedro151/orm-generator/v/unstable)](https://packagist.org/packages/pedro151/orm-generator)
[![License](https://poser.pugx.org/pedro151/orm-generator/license)](https://packagist.org/packages/pedro151/orm-generator)

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.
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.

Expand Down Expand Up @@ -57,7 +57,7 @@ framework-path-library = "C:\Apache24\htdocs\project\library"
PHP Code Generation
-------------------

Open the prompt in the directory `ORM-Generator` and write:
Open the prompt in the directory `orm-generator` and write:

```cmd
$ php generate.php
Expand All @@ -73,15 +73,15 @@ Configurations optionals
------------------------
| Command | description |
|----------------|------------------|
| --init | Creates the necessary configuration file to start using the ORM-Generator. |
| --init | Creates the necessary configuration file to start using the ORM Generator. |
| --config-ini | reference to another .ini file configuration (relative path). |
| --config-env | ORM-Generator configuration environment. |
| --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). |
| --status | show status of implementation carried out after completing the process. |
| --version | shows the version of ORM-Generator. |
| --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). |

Expand All @@ -91,7 +91,7 @@ Configurations optionals
in prompt

```cmd
$ php generate.php --framework=zend_framework --database=foo --driver=pgsql --status
$ php generate.php --framework=zf1 --database=foo --driver=pgsql --status
```

Support Database
Expand All @@ -106,7 +106,7 @@ Support Database
Framework Class Generator ORM
-----------------------------

| Frameworks | Config Name | Generate Classes |
|--------------------|-------------|------------------|
|Zend Framework 1.12 | zend_framework |DbTable, Entity, Model |

| Frameworks | Config Name | Version | Generate Classes |
|--------------------|----------------|:---------:|------------------|
|Zend Framework | zf1 | 1.12 | DbTable, Entity, Model |
|Phalcon | phalcon | 2.0.10 | Entity, Model |
Binary file modified bin/orm-generator.phar
Binary file not shown.
59 changes: 49 additions & 10 deletions build/Classes/AdapterConfig/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

namespace Classes\AdapterConfig;

use Classes\Maker\AbstractMaker;

require_once "Classes/Maker/AbstractMaker.php";
require_once 'Exception.php';

/**
* @author Pedro Alarcao <phacl151@gmail.com>
* @link https://github.com/pedro151
* @link https://github.com/pedro151/orm-generator
*/
abstract class AbstractAdapter
{
Expand Down Expand Up @@ -34,8 +37,8 @@ abstract class AbstractAdapter
// autor que gerou o script
'author' => "Pedro" ,
'license' => "New BSD License" ,
'copyright' => "DAO Generator-Pedro151" ,
'link' => 'https://github.com/pedro151' ,
'copyright' => "ORM Generator - Pedro151" ,
'link' => 'https://github.com/pedro151/orm-generator' ,
// data que foi gerado o script
'last_modify' => null ,

Expand Down Expand Up @@ -74,6 +77,8 @@ abstract class AbstractAdapter

private $framworkFiles = array ();

const SEPARETOR = "";

/**
* verifica se todos valores obrigatorios tem valor
*
Expand Down Expand Up @@ -103,13 +108,6 @@ abstract protected function getParams ();
*/
abstract protected function parseFrameworkConfig ();

/**
* @param \Classes\Db\DbTable|\Classes\Db\Constrant $table
*
* @return mixed
*/
abstract public function createClassNamespace ( $table );

/**
* Cria Instancias dos arquivos que devem ser gerados
*
Expand All @@ -119,6 +117,47 @@ abstract public function getMakeFileInstances ();

abstract protected function init ();

/**
* retorna a base do Namespace
*
* @return array
*/
protected function getBaseNamespace ()
{
return array (
$this->arrConfig[ 'namespace' ] ,
'Model'
);
}

/**
* @param \Classes\Db\DbTable|\Classes\Db\Constrant $table
*
* @return mixed
*/

public function createClassNamespace ( $table )
{
$arrNames = $this->getBaseNamespace ();

if ( isset( $this->arrConfig[ 'folder-database' ] )
&& $this->arrConfig[ 'folder-database' ]
)
{
$arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'driver' ] );
}

if ( $table->hasSchema () )
{
$arrNames[] = AbstractMaker::getClassName ( $table->getSchema () );
} else
{
$arrNames[] = AbstractMaker::getClassName ( $table->getDatabase () );
}

return implode ( static::SEPARETOR , array_filter ( $arrNames ) );
}

public function __construct ( $array )
{
$array += array (
Expand Down
2 changes: 1 addition & 1 deletion build/Classes/AdapterConfig/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/**
* @author Pedro Alarcao <phacl151@gmail.com>
* @link https://github.com/pedro151/ORM-Generator
* @link https://github.com/pedro151/orm-generator
*/
class Exception extends \Exception
{
Expand Down
19 changes: 1 addition & 18 deletions build/Classes/AdapterConfig/None.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/**
* @author Pedro Alarcao <phacl151@gmail.com>
* @link https://github.com/pedro151/ORM-Generator
* @link https://github.com/pedro151/orm-generator
*/
class None extends AbstractAdapter
{
Expand All @@ -41,23 +41,6 @@ protected function parseFrameworkConfig ()
// TODO: Implement parseFrameworkConfig() method.
}

public function createClassNamespace ( $table )
{
$arrNames = array (
$this->arrConfig[ 'namespace' ],
'Model'
);
if ( $table->hasSchema () )
{
$arrNames[] = AbstractMaker::getClassName ( $table->getSchema () );
} else
{
$arrNames[] = AbstractMaker::getClassName ( $table->getDatabase() );
}

return implode ( '_', array_filter ( $arrNames ) );
}

/**
* Cria Instancias dos arquivos que devem ser gerados
*
Expand Down
34 changes: 23 additions & 11 deletions build/Classes/AdapterConfig/Phalcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

namespace Classes\AdapterConfig;

use Classes\AdapterMakerFile\Phalcon\Entity;
use Classes\AdapterMakerFile\Phalcon\Model;

require_once "Classes/AdapterConfig/AbstractAdapter.php";
require_once "Classes/AdapterMakerFile/Phalcon/Entity.php";
require_once "Classes/AdapterMakerFile/Phalcon/Model.php";

/**
* @author Pedro Alarcao <phacl151@gmail.com>
* @link https://github.com/pedro151/ORM-Generator
* @link https://github.com/pedro151/orm-generator
*/
class Phalcon extends AbstractAdapter
{
Expand All @@ -15,7 +21,7 @@ class Phalcon extends AbstractAdapter
*/
protected $framework = "phalcon";

const SEPARETOR = "_";
const SEPARETOR = "\\";

protected function init ()
{
Expand All @@ -36,20 +42,24 @@ protected function parseFrameworkConfig ()
// TODO: Implement parseFrameworkConfig() method.
}

public function createClassNamespace ( $table )
/**
* @inheritdoc
*/
protected function getBaseNamespace ()
{
$arrNames = array (
$this->arrConfig[ 'namespace' ],
'Model'
);
if ( $table->hasSchema () )
if ( ! $this->arrConfig[ 'namespace' ] )
{
$arrNames[] = ucfirst ( $table->getSchema () );
return array (
'App' ,
'Model'
);
}

return implode ( '_', array_filter ( $arrNames ) );
return array (
$this->arrConfig[ 'namespace' ] ,
'Model'
);
}

/**
* Cria Instancias dos arquivos que devem ser gerados
*
Expand All @@ -58,6 +68,8 @@ public function createClassNamespace ( $table )
public function getMakeFileInstances ()
{
return array (
Entity::getInstance () ,
Model::getInstance ()
);
}

Expand Down
34 changes: 4 additions & 30 deletions build/Classes/AdapterConfig/ZendFrameworkOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
use Classes\AdapterMakerFile\ZendFrameworkOne\DbTable;
use Classes\AdapterMakerFile\ZendFrameworkOne\Entity;
use Classes\AdapterMakerFile\ZendFrameworkOne\Model;
use Classes\Maker\AbstractMaker;

require_once "Classes/Maker/AbstractMaker.php";
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";

/**
* @author Pedro Alarcao <phacl151@gmail.com>
* @link https://github.com/pedro151/ORM-Generator
* @link https://github.com/pedro151/orm-generator
*/
class ZendFrameworkOne extends AbstractAdapter
{
Expand All @@ -35,7 +33,7 @@ protected function init ()
*/
protected function getParams ()
{
if ( ! $this->config or !$this->isValidFrameworkFiles ())
if ( ! $this->config or ! $this->isValidFrameworkFiles () )
{
return array ();
}
Expand All @@ -59,7 +57,8 @@ protected function getParams ()

protected function parseFrameworkConfig ()
{
if(!$this->isValidFrameworkFiles ()){
if ( ! $this->isValidFrameworkFiles () )
{
return;
}

Expand All @@ -79,31 +78,6 @@ protected function parseFrameworkConfig ()
}
}

public function createClassNamespace ( $table )
{
$arrNames = array (
$this->arrConfig[ 'namespace' ] ,
'Model'
);

if ( isset( $this->arrConfig['folder-database'] )
&& $this->arrConfig['folder-database']
)
{
$arrNames[] = AbstractMaker::getClassName ( $this->arrConfig['driver'] );
}

if ( $table->hasSchema () )
{
$arrNames[] = AbstractMaker::getClassName ( $table->getSchema () );
} else
{
$arrNames[] = AbstractMaker::getClassName ( $table->getDatabase () );
}

return implode ( self::SEPARETOR , array_filter ( $arrNames ) );
}

/**
* Cria Instancias dos arquivos que devem ser gerados
*
Expand Down
10 changes: 4 additions & 6 deletions build/Classes/AdapterMakerFile/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* @author Pedro Alarcao <phacl151@gmail.com>
* @link https://github.com/pedro151/ORM-Generator
* @link https://github.com/pedro151/orm-generator
*/
abstract class AbstractAdapter
{
Expand All @@ -26,14 +26,12 @@ final private function __construct ()
public static function getInstance ()
{
$class = get_called_class ();
$arr = explode ( '\\', $class );
$classEnd = end ( $arr );
if ( !isset( self::$_instance[ $classEnd ] ) )
if ( !isset( self::$_instance[ $class ] ) )
{
self::$_instance[ $classEnd ] = new $class();
self::$_instance[ $class ] = new $class();
}

return self::$_instance[ $classEnd ];
return self::$_instance[ $class ];
}

/**
Expand Down

0 comments on commit e1c224e

Please sign in to comment.