From b3828cebd2fcd596ae4c8933a62864c50c8229fb Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Mon, 12 Sep 2022 16:59:26 +0100 Subject: [PATCH] MDL-75034 reportbuilder: move classes into consistent namespace. Use `reportbuilder` level two namespace for report related classes (entities, system reports, etc) within components and sub-systems. --- admin/classes/reportbuilder/datasource/task_logs.php | 2 +- .../{ => reportbuilder}/local/entities/task_log.php | 2 +- .../local/systemreports/task_logs.php | 4 ++-- admin/tasklogs.php | 2 +- cohort/classes/reportbuilder/datasource/cohorts.php | 3 +-- .../{ => reportbuilder}/local/entities/cohort.php | 2 +- .../local/entities/cohort_member.php | 2 +- course/classes/reportbuilder/datasource/courses.php | 2 +- .../classes/reportbuilder/datasource/participants.php | 2 +- .../local/entities/course_category.php | 2 +- lib/db/renamedclasses.php | 6 ++++++ .../local/entities/config_change.php | 2 +- .../local/systemreports/config_changes.php | 10 +++++----- .../configlog/{version.php => db/renamedclasses.php} | 19 +++++++++++-------- report/configlog/index.php | 2 +- report/configlog/version.php | 2 +- reportbuilder/upgrade.txt | 6 ++++++ 17 files changed, 42 insertions(+), 28 deletions(-) rename admin/classes/{ => reportbuilder}/local/entities/task_log.php (99%) rename admin/classes/{ => reportbuilder}/local/systemreports/task_logs.php (97%) rename cohort/classes/{ => reportbuilder}/local/entities/cohort.php (99%) rename cohort/classes/{ => reportbuilder}/local/entities/cohort_member.php (98%) rename course/classes/{ => reportbuilder}/local/entities/course_category.php (99%) rename report/configlog/classes/{ => reportbuilder}/local/entities/config_change.php (99%) rename report/configlog/classes/{ => reportbuilder}/local/systemreports/config_changes.php (93%) copy report/configlog/{version.php => db/renamedclasses.php} (57%) diff --git a/admin/classes/reportbuilder/datasource/task_logs.php b/admin/classes/reportbuilder/datasource/task_logs.php index a19744a90f5..d9d4b8864d8 100644 --- a/admin/classes/reportbuilder/datasource/task_logs.php +++ b/admin/classes/reportbuilder/datasource/task_logs.php @@ -18,10 +18,10 @@ declare(strict_types=1); namespace core_admin\reportbuilder\datasource; +use core_admin\reportbuilder\local\entities\task_log; use core_reportbuilder\datasource; use core_reportbuilder\local\entities\user; use core_reportbuilder\local\filters\select; -use core_admin\local\entities\task_log; /** * Task logs datasource diff --git a/admin/classes/local/entities/task_log.php b/admin/classes/reportbuilder/local/entities/task_log.php similarity index 99% rename from admin/classes/local/entities/task_log.php rename to admin/classes/reportbuilder/local/entities/task_log.php index 28d34c2a7f0..b276d591496 100644 --- a/admin/classes/local/entities/task_log.php +++ b/admin/classes/reportbuilder/local/entities/task_log.php @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace core_admin\local\entities; +namespace core_admin\reportbuilder\local\entities; use core_reportbuilder\local\filters\date; use core_reportbuilder\local\filters\duration; diff --git a/admin/classes/local/systemreports/task_logs.php b/admin/classes/reportbuilder/local/systemreports/task_logs.php similarity index 97% rename from admin/classes/local/systemreports/task_logs.php rename to admin/classes/reportbuilder/local/systemreports/task_logs.php index 9349415530e..be35ae3be6a 100644 --- a/admin/classes/local/systemreports/task_logs.php +++ b/admin/classes/reportbuilder/local/systemreports/task_logs.php @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace core_admin\local\systemreports; +namespace core_admin\reportbuilder\local\systemreports; use context_system; -use core_admin\local\entities\task_log; +use core_admin\reportbuilder\local\entities\task_log; use core_reportbuilder\local\entities\user; use core_reportbuilder\local\report\action; use lang_string; diff --git a/admin/tasklogs.php b/admin/tasklogs.php index f93814fb397..a2b94d4ae0e 100644 --- a/admin/tasklogs.php +++ b/admin/tasklogs.php @@ -25,7 +25,7 @@ require_once(__DIR__ . '/../config.php'); require_once("{$CFG->libdir}/adminlib.php"); -use core_admin\local\systemreports\task_logs; +use core_admin\reportbuilder\local\systemreports\task_logs; use core_reportbuilder\system_report_factory; $PAGE->set_url(new \moodle_url('/admin/tasklogs.php')); diff --git a/cohort/classes/reportbuilder/datasource/cohorts.php b/cohort/classes/reportbuilder/datasource/cohorts.php index ff3db1258af..6e49015cd48 100644 --- a/cohort/classes/reportbuilder/datasource/cohorts.php +++ b/cohort/classes/reportbuilder/datasource/cohorts.php @@ -18,8 +18,7 @@ declare(strict_types=1); namespace core_cohort\reportbuilder\datasource; -use core_cohort\local\entities\cohort; -use core_cohort\local\entities\cohort_member; +use core_cohort\reportbuilder\local\entities\{cohort, cohort_member}; use core_reportbuilder\datasource; use core_reportbuilder\local\entities\user; diff --git a/cohort/classes/local/entities/cohort.php b/cohort/classes/reportbuilder/local/entities/cohort.php similarity index 99% rename from cohort/classes/local/entities/cohort.php rename to cohort/classes/reportbuilder/local/entities/cohort.php index a086ca81b03..462a498f5c4 100644 --- a/cohort/classes/local/entities/cohort.php +++ b/cohort/classes/reportbuilder/local/entities/cohort.php @@ -16,7 +16,7 @@ declare(strict_types=1); -namespace core_cohort\local\entities; +namespace core_cohort\reportbuilder\local\entities; use context; use context_helper; diff --git a/cohort/classes/local/entities/cohort_member.php b/cohort/classes/reportbuilder/local/entities/cohort_member.php similarity index 98% rename from cohort/classes/local/entities/cohort_member.php rename to cohort/classes/reportbuilder/local/entities/cohort_member.php index b05a661714b..3d82cad7a28 100644 --- a/cohort/classes/local/entities/cohort_member.php +++ b/cohort/classes/reportbuilder/local/entities/cohort_member.php @@ -16,7 +16,7 @@ declare(strict_types=1); -namespace core_cohort\local\entities; +namespace core_cohort\reportbuilder\local\entities; use lang_string; use core_reportbuilder\local\entities\base; diff --git a/course/classes/reportbuilder/datasource/courses.php b/course/classes/reportbuilder/datasource/courses.php index 8e641b0f731..7a8e169577b 100644 --- a/course/classes/reportbuilder/datasource/courses.php +++ b/course/classes/reportbuilder/datasource/courses.php @@ -18,7 +18,7 @@ declare(strict_types=1); namespace core_course\reportbuilder\datasource; -use core_course\local\entities\course_category; +use core_course\reportbuilder\local\entities\course_category; use core_reportbuilder\datasource; use core_reportbuilder\local\entities\course; use core_reportbuilder\local\helpers\database; diff --git a/course/classes/reportbuilder/datasource/participants.php b/course/classes/reportbuilder/datasource/participants.php index 816f7d670aa..54fcfda7f93 100644 --- a/course/classes/reportbuilder/datasource/participants.php +++ b/course/classes/reportbuilder/datasource/participants.php @@ -18,7 +18,7 @@ declare(strict_types=1); namespace core_course\reportbuilder\datasource; -use core_course\local\entities\course_category; +use core_course\reportbuilder\local\entities\course_category; use core_course\reportbuilder\local\entities\access; use core_course\reportbuilder\local\entities\completion; use core_course\reportbuilder\local\entities\enrolment; diff --git a/course/classes/local/entities/course_category.php b/course/classes/reportbuilder/local/entities/course_category.php similarity index 99% rename from course/classes/local/entities/course_category.php rename to course/classes/reportbuilder/local/entities/course_category.php index 4794cd2f154..85a0bf28c94 100644 --- a/course/classes/local/entities/course_category.php +++ b/course/classes/reportbuilder/local/entities/course_category.php @@ -16,7 +16,7 @@ declare(strict_types=1); -namespace core_course\local\entities; +namespace core_course\reportbuilder\local\entities; use context_coursecat; use context_helper; diff --git a/lib/db/renamedclasses.php b/lib/db/renamedclasses.php index 39d6de58801..1333e61aecf 100644 --- a/lib/db/renamedclasses.php +++ b/lib/db/renamedclasses.php @@ -83,4 +83,10 @@ $renamedclasses = [ 'core_question\\form\\tags' => 'qbank_tagquestion\\form\\tags_form', 'context_to_string_translator' => 'core_question\\local\\bank\\context_to_string_translator', 'question_edit_contexts' => 'core_question\\local\\bank\\question_edit_contexts', + // Since Moodle 4.1. + 'core_admin\\local\\systemreports\\task_logs' => 'core_admin\\reportbuilder\\local\\systemreports\\task_logs', + 'core_admin\\local\\entities\\task_log' => 'core_admin\\reportbuilder\\local\\entities\\task_log', + 'core_course\\local\\entities\\course_category' => 'core_course\\reportbuilder\\local\\entities\\course_category', + 'core_cohort\\local\\entities\\cohort' => 'core_cohort\\reportbuilder\\local\\entities\\cohort', + 'core_cohort\\local\\entities\\cohort_member' => 'core_cohort\\reportbuilder\\local\\entities\\cohort_member', ]; diff --git a/report/configlog/classes/local/entities/config_change.php b/report/configlog/classes/reportbuilder/local/entities/config_change.php similarity index 99% rename from report/configlog/classes/local/entities/config_change.php rename to report/configlog/classes/reportbuilder/local/entities/config_change.php index 7ba29cb83c2..53695e74967 100644 --- a/report/configlog/classes/local/entities/config_change.php +++ b/report/configlog/classes/reportbuilder/local/entities/config_change.php @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace report_configlog\local\entities; +namespace report_configlog\reportbuilder\local\entities; use lang_string; use core_reportbuilder\local\entities\base; diff --git a/report/configlog/classes/local/systemreports/config_changes.php b/report/configlog/classes/reportbuilder/local/systemreports/config_changes.php similarity index 93% rename from report/configlog/classes/local/systemreports/config_changes.php rename to report/configlog/classes/reportbuilder/local/systemreports/config_changes.php index 90973fb1eb2..4f4afb6e12c 100644 --- a/report/configlog/classes/local/systemreports/config_changes.php +++ b/report/configlog/classes/reportbuilder/local/systemreports/config_changes.php @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace report_configlog\local\systemreports; +namespace report_configlog\reportbuilder\local\systemreports; use context_system; -use report_configlog\local\entities\config_change as config_change_entity; +use report_configlog\reportbuilder\local\entities\config_change; use core_reportbuilder\system_report; -use core_reportbuilder\local\entities\user as user_entity; +use core_reportbuilder\local\entities\user; use stdClass; /** @@ -36,14 +36,14 @@ class config_changes extends system_report { */ protected function initialise(): void { // Our main entity, it contains all of the column definitions that we need. - $entitymain = new config_change_entity(); + $entitymain = new config_change(); $entitymainalias = $entitymain->get_table_alias('config_log'); $this->set_main_table('config_log', $entitymainalias); $this->add_entity($entitymain); // We can join the "user" entity to our "main" entity using standard SQL JOIN. - $entityuser = new user_entity(); + $entityuser = new user(); $entityuseralias = $entityuser->get_table_alias('user'); $this->add_entity($entityuser ->add_join("LEFT JOIN {user} {$entityuseralias} ON {$entityuseralias}.id = {$entitymainalias}.userid") diff --git a/report/configlog/version.php b/report/configlog/db/renamedclasses.php similarity index 57% copy from report/configlog/version.php copy to report/configlog/db/renamedclasses.php index 1bd30be0e26..cde301e00c0 100644 --- a/report/configlog/version.php +++ b/report/configlog/db/renamedclasses.php @@ -15,16 +15,19 @@ // along with Moodle. If not, see . /** - * Version details. + * This file contains mappings for classes that have been renamed so that they meet the requirements of the autoloader. * - * @package report - * @subpackage configlog - * @copyright 2011 Petr Skoda + * @package report_configlog + * @copyright 2022 Paul Holden * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die; +defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022041900; // The current plugin version (Date: YYYYMMDDXX). -$plugin->requires = 2022041200; // Requires this Moodle version. -$plugin->component = 'report_configlog'; // Full name of the plugin (used for diagnostics) +$renamedclasses = [ + // Since Moodle 4.1. + 'report_configlog\\local\\systemreports\\config_changes' => + 'report_configlog\\reportbuilder\\local\\systemreports\\config_changes', + 'report_configlog\\local\\entities\\config_change' => + 'report_configlog\\reportbuilder\\local\\entities\\config_change', +]; diff --git a/report/configlog/index.php b/report/configlog/index.php index b360a2226cf..6b40c17d329 100644 --- a/report/configlog/index.php +++ b/report/configlog/index.php @@ -25,7 +25,7 @@ use core_reportbuilder\system_report_factory; use core_reportbuilder\local\filters\text; -use report_configlog\local\systemreports\config_changes; +use report_configlog\reportbuilder\local\systemreports\config_changes; require(__DIR__.'/../../config.php'); require_once($CFG->libdir.'/adminlib.php'); diff --git a/report/configlog/version.php b/report/configlog/version.php index 1bd30be0e26..5c54d907687 100644 --- a/report/configlog/version.php +++ b/report/configlog/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2022041900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2022091500; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->component = 'report_configlog'; // Full name of the plugin (used for diagnostics) diff --git a/reportbuilder/upgrade.txt b/reportbuilder/upgrade.txt index d8f6b381090..dc06d789035 100644 --- a/reportbuilder/upgrade.txt +++ b/reportbuilder/upgrade.txt @@ -12,6 +12,12 @@ Information provided here is intended especially for developers. * New external methods for retrieving custom report data: - `core_reportbuilder_list_reports` - `core_reportbuilder_view_report` +* For consistency, the following entity classes have moved namespace (usage of previous namespace will generate debugging): + - `core_admin\{ => reportbuilder}\local\entities\task_log` + - `core_cohort\{ => reportbuilder}\local\entities\cohort` + - `core_cohort\{ => reportbuilder}\local\entities\cohort_member` + - `core_course\{ => reportbuilder}\local\entities\course_category` + - `report_configlog\{ => reportbuilder}\local\entities\config_change` * 'set_default_per_page' and 'get_default_per_page' methods have been added to \local\report\base class to manage the default displayed rows per page. * Added two new methods in the datasource class: -- 2.11.4.GIT