From dc240e47b91b4095e36bea4e8259e55cc812ce0c Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 24 Aug 2014 21:18:03 +0300 Subject: [PATCH] cleanup --- ipf/legacy_orm/app.php | 1 - .../commands/buildcontribmodels.php | 21 ------------------- ipf/legacy_orm/commands/buildmodels.php | 13 ++---------- ipf/legacy_orm/commands/fixtures.php | 2 +- ipf/legacy_orm/commands/sql.php | 13 ++---------- ipf/legacy_orm/orm.php | 8 +++++++ 6 files changed, 13 insertions(+), 45 deletions(-) delete mode 100644 ipf/legacy_orm/commands/buildcontribmodels.php diff --git a/ipf/legacy_orm/app.php b/ipf/legacy_orm/app.php index 8aa0019..4cc3472 100644 --- a/ipf/legacy_orm/app.php +++ b/ipf/legacy_orm/app.php @@ -39,7 +39,6 @@ class IPF_Legacy_ORM_App extends IPF_Application { return array( new IPF_Legacy_ORM_Command_BuildModels, - new IPF_Legacy_ORM_Command_BuildContribModels, new IPF_Legacy_ORM_Command_Sql, new IPF_Legacy_ORM_Command_SyncDB, new IPF_Legacy_ORM_Command_Fixtures, diff --git a/ipf/legacy_orm/commands/buildcontribmodels.php b/ipf/legacy_orm/commands/buildcontribmodels.php deleted file mode 100644 index 4ffd5f3..0000000 --- a/ipf/legacy_orm/commands/buildcontribmodels.php +++ /dev/null @@ -1,21 +0,0 @@ -frameworkApps() as $app) { - $models = IPF_ORM::generateModelsFromYaml($app->path, $extraAllwedReferences); - $extraAllwedReferences = array_merge($extraAllwedReferences, $models); - } - } -} - diff --git a/ipf/legacy_orm/commands/buildmodels.php b/ipf/legacy_orm/commands/buildmodels.php index 0e2e9b8..9dca874 100644 --- a/ipf/legacy_orm/commands/buildmodels.php +++ b/ipf/legacy_orm/commands/buildmodels.php @@ -12,19 +12,10 @@ class IPF_Legacy_ORM_Command_BuildModels $project = IPF_Project::getInstance(); $paths = array(); - foreach ($project->customApps() as $app) + foreach ($project->appList() as $app) $paths[] = $app->getPath(); - $extraAllowedReferences = $this->frameworkModels($project); - IPF_ORM::generateModelsFromYaml($paths, $extraAllowedReferences); - } - - private function frameworkModels($project) - { - $models = array(); - foreach ($project->frameworkApps() as $app) - $models = array_merge($models, IPF_Legacy_ORM_App::appModelList($app)); - return $models; + IPF_ORM::generateModelsFromYaml($paths, array()); } } diff --git a/ipf/legacy_orm/commands/fixtures.php b/ipf/legacy_orm/commands/fixtures.php index 0b5689a..3c6e279 100644 --- a/ipf/legacy_orm/commands/fixtures.php +++ b/ipf/legacy_orm/commands/fixtures.php @@ -12,7 +12,7 @@ class IPF_Legacy_ORM_Command_Fixtures $project = IPF_Project::getInstance(); $paths = array(IPF::get('project_path')); - foreach ($project->customApps() as $app) + foreach ($project->appList() as $app) $paths[] = $app->path; $fixtures = array(); diff --git a/ipf/legacy_orm/commands/sql.php b/ipf/legacy_orm/commands/sql.php index 5bc9c2d..31f55c9 100644 --- a/ipf/legacy_orm/commands/sql.php +++ b/ipf/legacy_orm/commands/sql.php @@ -9,17 +9,8 @@ class IPF_Legacy_ORM_Command_Sql { print "Show all SQL DDL from model classes\n"; - $project = IPF_Project::getInstance(); - - $sql = ''; - - foreach ($project->frameworkApps() as $app) - $sql .= IPF_ORM::generateSqlFromModels($app)."\n"; - - foreach ($project->customApps() as $app) - $sql .= IPF_ORM::generateSqlFromModels($app)."\n"; - - print $sql; + foreach (IPF_Project::getInstance()->appList() as $app) + print IPF_ORM::generateSqlFromModels($app)."\n"; } } diff --git a/ipf/legacy_orm/orm.php b/ipf/legacy_orm/orm.php index 660c0a9..f5fb916 100644 --- a/ipf/legacy_orm/orm.php +++ b/ipf/legacy_orm/orm.php @@ -243,5 +243,13 @@ final class IPF_ORM return implode("\n", $ret); } + + public static function GetObjectOr404($object, $id) + { + $obj = IPF_ORM::getTable($object)->findOneById($id); + if ($obj) + return $obj; + throw new IPF_HTTP_Error404(); + } } -- 2.49.0