]> git.andy128k.dev Git - ipf.git/commitdiff
load all models on start (required by syncperms command and admin app)
authorAndrey Kutejko <andy128k@gmail.com>
Sun, 14 Jul 2013 09:43:51 +0000 (12:43 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sun, 14 Jul 2013 09:43:51 +0000 (12:43 +0300)
ipf/auth/app.php
ipf/command/syncperms.php
ipf/project.php

index a5295a9962a6a7c87979321255ee3fb5e8b5a0fe..8ff7be88021f8d4a52a163c9c3a0b6f7a8042a21 100644 (file)
@@ -33,12 +33,15 @@ class IPF_Auth_App extends IPF_Application
         $request->session->setData('logout_time', gmdate('Y-m-d H:i:s'));
     }
 
-    static function createPermissionsFromModels(array $apps)
+    static function createPermissionsFromModels()
     {
         $permsTable = IPF_ORM::getTable('Permission');
 
+        $project = IPF_Project::getInstance();
+        $project->loadAllModels();
+
         $permissions = array();
-        foreach ($apps as $appname => $app) {
+        foreach ($project->appList() as $appname => $app) {
             foreach ($app->modelList() as $modelName) {
                 $adminModel = IPF_Admin_Model::getModelAdmin($modelName);
                 if ($adminModel) {
index 9aadb85167625a3f3852c02cd95fe2e13096522a..f2158d0f801a180f73661c3d6d5213fadebc8b7e 100644 (file)
@@ -8,9 +8,7 @@ class IPF_Command_SyncPerms
     public function run($args=null)
     {
         print "Create/Update permissions from model classes\n";
-
-        $project = IPF_Project::getInstance();
-        return IPF_Auth_App::createPermissionsFromModels($project->appList());
+        IPF_Auth_App::createPermissionsFromModels();
     }
 }
 
index d30aa488e38e9d677effaebdcf492d4573f5f569..3ba120526ad1d80b24c2717012ec4c538afbbad0 100644 (file)
@@ -83,6 +83,13 @@ final class IPF_Project
         return $result;
     }
 
+    public function loadAllModels()
+    {
+        foreach ($this->appList() as $appname => $app)
+            foreach ($app->modelList() as $modelName)
+                new $modelName;
+    }
+
     public function run()
     {
         if (IPF::get('debug')) {
@@ -98,6 +105,7 @@ final class IPF_Project
             $cli = new IPF_Cli;
             $cli->run();
         } else {
+            $this->loadAllModels();
             $this->router->dispatch(IPF_HTTP_URL::getAction());
         }