From 2e79d24f1a321c6f8c3927f2b9467754e55e3b74 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sat, 17 Dec 2016 19:12:09 +0100 Subject: [PATCH] pass project to application --- ipf/application.php | 22 +++++++++++++++++----- ipf/project.php | 3 ++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ipf/application.php b/ipf/application.php index 47264c6..71bb436 100644 --- a/ipf/application.php +++ b/ipf/application.php @@ -2,14 +2,25 @@ abstract class IPF_Application { - protected $name = null; + /** @var IPF_Project */ + private $project; - public function __construct($data=array()) + /** @var string */ + private $name, $path; + + public function __construct(IPF_Project $project) { + $this->project = $project; + $this->name = preg_replace('/_App$/', '', get_class($this)); $rc = new ReflectionClass($this); - $this->path = dirname($rc->getFileName()).DIRECTORY_SEPARATOR; + $this->path = dirname($rc->getFileName()) . DIRECTORY_SEPARATOR; + } + + public function getProject() + { + return $this->project; } public function getName() @@ -34,8 +45,10 @@ abstract class IPF_Application /** * Configures application + * + * @param IPF_Settings $settings */ - public function configure($settings) + public function configure(IPF_Settings $settings) { } @@ -69,4 +82,3 @@ abstract class IPF_Application return array(); } } - diff --git a/ipf/project.php b/ipf/project.php index b3ac3a9..4da1fae 100644 --- a/ipf/project.php +++ b/ipf/project.php @@ -19,7 +19,8 @@ final class IPF_Project { foreach (IPF::get('applications') as $name) { $className = $name.'_App'; - $app = new $className; + /** @var IPF_Application $app */ + $app = new $className($this); $app->configure(IPF::$settings); $this->apps[$name] = $app; -- 2.49.0