From: Andrey Kutejko Date: Sun, 24 Aug 2014 18:18:03 +0000 (+0300) Subject: cleanup X-Git-Tag: 0.6~165 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=5ff69688e2eaa0e04125d2b5df13f472a6a8bd27;p=ipf.git cleanup --- diff --git a/ipf/admin/templates/admin/index.html b/ipf/admin/templates/admin/index.html index 34f7272..50bfc1f 100644 --- a/ipf/admin/templates/admin/index.html +++ b/ipf/admin/templates/admin/index.html @@ -18,11 +18,6 @@ {trans 'Change'} {/foreach} - {foreach $app.additions as $item} - - {$item['title']} - - {/foreach} diff --git a/ipf/admin/views.php b/ipf/admin/views.php index e65d44b..f5b725b 100644 --- a/ipf/admin/views.php +++ b/ipf/admin/views.php @@ -19,7 +19,6 @@ function IPF_Admin_Views_Index($request, $match) $app_list[] = (object)array( 'name' => $app->getTitle(), 'path' => $app->slug(), - 'additions' => $app->getAdditions(), 'components' => $components, ); } diff --git a/ipf/application.php b/ipf/application.php index fc138f4..1fe3efe 100644 --- a/ipf/application.php +++ b/ipf/application.php @@ -6,7 +6,7 @@ abstract class IPF_Application public function __construct($data=array()) { - $this->name = str_replace('_App', '', get_class($this)); + $this->name = preg_replace('/_App$/', '', get_class($this)); $rc = new ReflectionClass($this); $this->path = dirname($rc->getFileName()).DIRECTORY_SEPARATOR; @@ -17,16 +17,6 @@ abstract class IPF_Application return $this->name; } - public function getLabel() - { - return str_replace('ipf_','',strtolower($this->name)); - } - - public function getAdditions() - { - return array(); - } - public function getTitle() { return $this->name; diff --git a/ipf/command/migrate.php b/ipf/command/migrate.php index cb6b949..ac7ddd4 100644 --- a/ipf/command/migrate.php +++ b/ipf/command/migrate.php @@ -10,7 +10,7 @@ class IPF_Command_Migrate $project = IPF_Project::getInstance(); $paths = array(IPF::get('project_path').'/db/migrations'); - foreach ($project->frameworkApps() as $app) { + foreach ($project->appList() as $app) { $paths[] = $app->getPath() . 'migrations'; } 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(); + } } diff --git a/ipf/project.php b/ipf/project.php index 8bb7ded..ff9c303 100644 --- a/ipf/project.php +++ b/ipf/project.php @@ -17,11 +17,9 @@ final class IPF_Project private function __construct() { - $applist = IPF::get('applications'); - foreach ($applist as &$appname) { - if (!IPF_Utils::isValidName($appname)) - throw new IPF_Exception_Panic("Application name \"$name\" is incorrect"); - $this->apps[$appname] = null; + foreach (IPF::get('applications') as $name) { + $className = $name.'_App'; + $this->apps[$name] = new $className; } $this->router = new IPF_Router; } @@ -32,46 +30,9 @@ final class IPF_Project public function appList() { - foreach($this->apps as $appName => &$app) { - if ($app == null) { - $app = $this->getApp($appName); - } - } return $this->apps; } - // Lazy Application Loader - public function getApp($name) - { - if (!array_key_exists($name, $this->apps)) - throw new IPF_Exception_Panic("Application \"$name\" not found"); - if ($this->apps[$name] == null) { - $className = $name.'_App'; - $this->apps[$name] = new $className; - } - return $this->apps[$name]; - } - - public function frameworkApps() - { - $result = array(); - foreach ($this->apps as $appname => &$app) { - if (substr($appname, 0, 4) === 'IPF_') - $result[] = $this->getApp($appname); - } - return $result; - } - - public function customApps() - { - $result = array(); - foreach ($this->apps as $appname => &$app) { - if (substr($appname, 0, 4) !== 'IPF_') - $result[] = $this->getApp($appname); - } - return $result; - } - public function run() { \PFF\Container::setFactory('databaseConnection', array('IPF_Database', 'connect')); diff --git a/ipf/shortcuts.php b/ipf/shortcuts.php index f3609ad..6c1093c 100644 --- a/ipf/shortcuts.php +++ b/ipf/shortcuts.php @@ -2,14 +2,6 @@ final class IPF_Shortcuts { - public static function GetObjectOr404($object, $id) - { - $obj = IPF_ORM::getTable($object)->findOneById($id); - if ($obj) - return $obj; - throw new IPF_HTTP_Error404(); - } - public static function RenderToResponse($tplfile, $params=array(), $request=null) { return new IPF_HTTP_Response(IPF_Shortcuts::RenderToString($tplfile, $params, $request));