From 92594aa8062f576a48716e93ff616894e417dcbf Mon Sep 17 00:00:00 2001
From: xamgore <xamgore@ya.ru>
Date: Mon, 1 Jun 2015 01:32:42 +0300
Subject: [PATCH] Renamed `toArray` method to `load`

---
 .../classes/Controller/Admin/Accounts.php          |  3 +--
 .../classes/Controller/Admin/Students.php          |  6 +++---
 .../classes/Controller/Admin/Subjects.php          |  2 +-
 .../classes/Controller/Admin/Teachers.php          |  6 +++---
 .../classes/Controller/DeanOffice/Students.php     |  2 +-
 .../classes/Controller/Teacher/Discipline.php      |  6 +++---
 .../application/classes/Model/Faculties.php        | 14 +++-----------
 7 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/~dev_rating/application/classes/Controller/Admin/Accounts.php b/~dev_rating/application/classes/Controller/Admin/Accounts.php
index 1c100dedd..f5b862405 100644
--- a/~dev_rating/application/classes/Controller/Admin/Accounts.php
+++ b/~dev_rating/application/classes/Controller/Admin/Accounts.php
@@ -12,10 +12,9 @@ class Controller_Admin_Accounts extends Controller_UserEnvironment {
     
     public function action_getActivationCodes()
     {
-        $model = new Model_Students();
         Cookie::set('fD', 'true');
         $twig = Twig::factory('admin/accounts/codes');
-        $twig->Faculties = Model_Faculties::toArray();
+        $twig->Faculties = Model_Faculties::load();
         $twig->Grades = Model_Grades::toStructuredArray();
         $twig->User = $this->user;
         $this->response->body($twig);
diff --git a/~dev_rating/application/classes/Controller/Admin/Students.php b/~dev_rating/application/classes/Controller/Admin/Students.php
index ecbd1cb3e..158ab9bae 100644
--- a/~dev_rating/application/classes/Controller/Admin/Students.php
+++ b/~dev_rating/application/classes/Controller/Admin/Students.php
@@ -6,7 +6,7 @@ class Controller_Admin_Students extends Controller_UserEnvironment {
     {
         // VIEW
         $twig = Twig::factory('admin/students/index');
-        $twig->Faculties = Model_Faculties::toArray();
+        $twig->Faculties = Model_Faculties::load();
         $twig->Grades = Model_Grades::toStructuredArray();
         $twig->User = $this->user;
         $this->response->body($twig);        
@@ -15,7 +15,7 @@ class Controller_Admin_Students extends Controller_UserEnvironment {
     public function action_add()
     {
         $twig = Twig::factory('admin/students/add');
-        $twig->Faculties = Model_Faculties::toArray();
+        $twig->Faculties = Model_Faculties::load();
         $twig->Grades = Model_Grades::toStructuredArray();
         $twig->User = $this->user;
         $this->response->body($twig);
@@ -29,7 +29,7 @@ class Controller_Admin_Students extends Controller_UserEnvironment {
         }
         // VIEW
         $twig = Twig::factory('admin/students/upload');
-        $twig->Faculties = Model_Faculties::toArray();
+        $twig->Faculties = Model_Faculties::load();
         $twig->UploadingResult = $result;
         $twig->User = $this->user;
         $this->response->body($twig);
diff --git a/~dev_rating/application/classes/Controller/Admin/Subjects.php b/~dev_rating/application/classes/Controller/Admin/Subjects.php
index b14d43a2d..d96b8eca3 100644
--- a/~dev_rating/application/classes/Controller/Admin/Subjects.php
+++ b/~dev_rating/application/classes/Controller/Admin/Subjects.php
@@ -13,7 +13,7 @@ class Controller_Admin_Subjects extends Controller_UserEnvironment {
         }
         // VIEW
         $twig = Twig::factory('admin/subjects/upload');
-        $twig->Faculties = Model_Faculties::toArray();
+        $twig->Faculties = Model_Faculties::load();
         $twig->UploadingResult = $result;
         $twig->User = $this->user;
         $this->response->body($twig);
diff --git a/~dev_rating/application/classes/Controller/Admin/Teachers.php b/~dev_rating/application/classes/Controller/Admin/Teachers.php
index cab950ed5..f0ccd5046 100644
--- a/~dev_rating/application/classes/Controller/Admin/Teachers.php
+++ b/~dev_rating/application/classes/Controller/Admin/Teachers.php
@@ -6,7 +6,7 @@ class Controller_Admin_Teachers extends Controller_UserEnvironment {
     {
         // VIEW
         $twig = Twig::factory('admin/teachers/index');
-        $twig->Faculties = Model_Faculties::toArray();
+        $twig->Faculties = Model_Faculties::load();
         $twig->User = $this->user;
         $this->response->body($twig);
     }
@@ -15,7 +15,7 @@ class Controller_Admin_Teachers extends Controller_UserEnvironment {
     {
         $twig = Twig::factory('admin/teachers/add');
         $twig->JobPositions = $this->getJobPositions();
-        $twig->Faculties = Model_Faculties::toArray();
+        $twig->Faculties = Model_Faculties::load();
         $twig->User = $this->user;
         $this->response->body($twig);
     }
@@ -28,7 +28,7 @@ class Controller_Admin_Teachers extends Controller_UserEnvironment {
         }
         // VIEW
         $twig = Twig::factory('admin/teachers/upload');
-        $twig->Faculties = Model_Faculties::toArray();
+        $twig->Faculties = Model_Faculties::load();
         $twig->UploadingResult = $result;
         $twig->User = $this->user;
         $this->response->body($twig);
diff --git a/~dev_rating/application/classes/Controller/DeanOffice/Students.php b/~dev_rating/application/classes/Controller/DeanOffice/Students.php
index f49edd24e..2ce11d2bf 100644
--- a/~dev_rating/application/classes/Controller/DeanOffice/Students.php
+++ b/~dev_rating/application/classes/Controller/DeanOffice/Students.php
@@ -4,7 +4,7 @@ class Controller_DeanOffice_Students extends Controller_UserEnvironment
 {
     public function action_index() {
         $twig = Twig::factory('dean_office/students/index');
-        $twig->Faculties = Model_Faculties::toArray();
+        $twig->Faculties = Model_Faculties::load();
         $twig->Grades = Model_Grades::toStructuredArray();
         $twig->User = $this->user;
         $this->response->body($twig);
diff --git a/~dev_rating/application/classes/Controller/Teacher/Discipline.php b/~dev_rating/application/classes/Controller/Teacher/Discipline.php
index 20948c0fa..3fc9753f7 100644
--- a/~dev_rating/application/classes/Controller/Teacher/Discipline.php
+++ b/~dev_rating/application/classes/Controller/Teacher/Discipline.php
@@ -7,7 +7,7 @@ class Controller_Teacher_Discipline extends Controller_UserEnvironment {
         $twig = Twig::factory('teacher/discipline/CreateDiscipline');
 
         $twig->User = $this->user;
-        $twig->FacultiesList = Model_Faculties::toArray();
+        $twig->FacultiesList = Model_Faculties::load();
         $twig->SubjectsList = Model_Subjects::byFaculty($this->user['FacultyID']);
         $twig->GradesList = Model_Grades::toArray();
 
@@ -19,7 +19,7 @@ class Controller_Teacher_Discipline extends Controller_UserEnvironment {
         $twig = Twig::factory('teacher/discipline/CreateCoursework');
 
         $twig->User = $this->user;
-        $twig->FacultiesList = Model_Faculties::toArray();
+        $twig->FacultiesList = Model_Faculties::load();
         $twig->SubjectsList = Model_Subjects::byFaculty($this->user['FacultyID']);
         $twig->GradesList = Model_Grades::toArray();
 
@@ -144,7 +144,7 @@ class Controller_Teacher_Discipline extends Controller_UserEnvironment {
         $twig->User = $this->user;
         $twig->Discipline = $this->getDisciplineInfo($id);
         $twig->BindTeachersList = Model_Teachers::getNamesForDiscipline($id);
-        $twig->FacultiesList = Model_Faculties::toArray();
+        $twig->FacultiesList = Model_Faculties::load();
         $twig->Departments = Model_Departments::byFaculty($this->user['FacultyID']);
         $twig->Author = Model_Account::getPersonalInfo($twig->Discipline['AuthorID']);
 
diff --git a/~dev_rating/application/classes/Model/Faculties.php b/~dev_rating/application/classes/Model/Faculties.php
index 83ad3a47c..82ecb8d43 100644
--- a/~dev_rating/application/classes/Model/Faculties.php
+++ b/~dev_rating/application/classes/Model/Faculties.php
@@ -2,17 +2,9 @@
 
 class Model_Faculties extends Model
 {
-    public static function getFaculties() {
+    public static function load() {
         $sql = "CALL `GetFaculties`(); ";
-        return DB::query(Database::SELECT, $sql)->execute();
-    }
-
-    public static function toArray() {
-        $faculties = self::getFaculties();
-
-        $list = array();
-        foreach ($faculties as $row)
-            $list[] = $row;
-        return $list;
+        return DB::query(Database::SELECT, $sql)
+            ->execute()->as_array();
     }
 }
-- 
GitLab