$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;
}
--- /dev/null
+<?php
+
+interface IPF_Admin_ISection
+{
+ /**
+ * @param IPF_Project $project
+ * @param IPF_Application $app
+ * @return IPF_Admin_Component[]
+ */
+ public function components(IPF_Project $project, IPF_Application $app);
+}
+
+class IPF_Admin_SimpleSection implements IPF_Admin_ISection
+{
+ /** @var array */
+ private $component_names;
+
+ public function __construct(array $component_names)
+ {
+ $this->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;
+ }
+}