From f7510b816cffc7b4719e60f06469035d417c780a Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sat, 17 Dec 2016 20:52:06 +0100 Subject: [PATCH] introduce admin section interface --- ipf/admin/app.php | 9 ++++++--- ipf/admin/section.php | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 ipf/admin/section.php diff --git a/ipf/admin/app.php b/ipf/admin/app.php index 269caa4..b4e97cd 100644 --- a/ipf/admin/app.php +++ b/ipf/admin/app.php @@ -89,9 +89,12 @@ class IPF_Admin_App extends IPF_Application $components = array(); if (is_file($app->getPath().'/admin.php')) { - $list = require_once $app->getPath().'/admin.php'; - foreach ($list as $c) { - $component = is_string($c) ? new $c : $c; + $section = require_once $app->getPath().'/admin.php'; + if (!($section instanceof IPF_Admin_ISection)) { + $section = new IPF_Admin_SimpleSection($section); + } + + foreach ($section->components($this->getProject(), $app) as $component) { $component->app = $app; $components[] = $component; } diff --git a/ipf/admin/section.php b/ipf/admin/section.php new file mode 100644 index 0000000..1f2cac7 --- /dev/null +++ b/ipf/admin/section.php @@ -0,0 +1,37 @@ +component_names = $component_names; + } + + /** + * @param IPF_Project $project + * @param IPF_Application $app + * @return IPF_Admin_Component[] + */ + public function components(IPF_Project $project, IPF_Application $app) + { + $components = array(); + foreach ($this->component_names as $c) { + $component = is_string($c) ? new $c : $c; + $components[] = $component; + } + return $components; + } +} -- 2.49.0