-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #35: Removendo contantes de configuração. #37
base: master
Are you sure you want to change the base?
Changes from 2 commits
c6b06c2
ffc48f9
f319875
859d7a5
17c9a30
483a99c
949e131
5ab5ae5
0c83bb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
namespace PseudoORM\Factory; | ||
|
||
use PseudoORM\Entity\EntidadeBase; | ||
use PseudoORM\DAO\GenericDAO; | ||
use \Exception; | ||
|
||
class AppFactory | ||
|
@@ -33,17 +32,18 @@ public static function getFactory() | |
|
||
public static function getRepository(EntidadeBase $objeto) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it static? |
||
{ | ||
try { | ||
$class = get_class($objeto); | ||
$respositoryPath = DAOS . $class . 'DAO.php'; | ||
if (!file_exists($respositoryPath)) { | ||
return new GenericDAO($class); | ||
} | ||
require_once $respositoryPath; | ||
$repository = $class . 'DAO'; | ||
return new $repository; | ||
} catch (Exception $e) { | ||
throw new Exception($e->getMessage()); | ||
} | ||
$class = get_class($objeto); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya don't need to get the name of class, just use |
||
$classShortName = (new \ReflectionClass($objeto))->getShortName(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no caso dessas ReflectionClass a função vai pegar o nome da classe ao invés de precisar fazer um require_once ? |
||
|
||
$classDAO = '\\PseudoORM\\DAO\\' . $classShortName . 'DAO'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should a DI be used instead? |
||
|
||
$entityName = class_exists($classDAO) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if my repository is an anonymous class? |
||
? $classShortName | ||
: 'Generic' | ||
; | ||
|
||
$repository = '\\PseudoORM\\DAO\\' . $entityName . 'DAO'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Repositories should be configured in some kind of mapping file — |
||
|
||
return new $repository($class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,6 @@ define('ENCODING', "SET NAMES 'utf8';"); | |
define("DB_DSN", "pgsql:host=".DB_HOST.";port=".DB_PORT.";dbname=".DB_NAME.";"); | ||
define("SHOW_SQL_ERROR", PDO::ERRMODE_EXCEPTION); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe mark this constants to be removed in the future as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. marquei como |
||
|
||
define('MODELS', '../app/models/'); | ||
define('DAOS', MODELS . 'DAO/impl/'); | ||
define('EXCEPTIONS', MODELS . 'exception/'); | ||
|
||
use PseudoORM\Entity\Usuario; | ||
use PseudoORM\Factory\AppFactory; | ||
use PseudoORM\Services\PostgreSQLDataBaseCreator; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sth?