module() public method

Access a project module config
public module ( string $name ) : Config
$name string
return Pop\Config
 /**
  * Constructor method to instantiate the default controller object
  *
  * @param  Request  $request
  * @param  Response $response
  * @param  Project  $project
  * @param  string   $viewPath
  * @return self
  */
 public function __construct(Request $request = null, Response $response = null, Project $project = null, $viewPath = null)
 {
     if (null === $viewPath) {
         $cfg = $project->module('Phire')->asArray();
         $viewPath = __DIR__ . '/../../../../../view/phire/install';
         if (isset($cfg['view'])) {
             $class = get_class($this);
             if (is_array($cfg['view']) && isset($cfg['view'][$class])) {
                 $viewPath = $cfg['view'][$class];
             } else {
                 if (is_array($cfg['view']) && isset($cfg['view']['*'])) {
                     $viewPath = $cfg['view']['*'] . '/install';
                 } else {
                     if (is_string($cfg['view'])) {
                         $viewPath = $cfg['view'] . '/install';
                     }
                 }
             }
         }
     }
     $lang = isset($_GET['lang']) ? $_GET['lang'] : 'en_US';
     if (!defined('POP_LANG')) {
         define('POP_LANG', $lang);
     }
     $this->i18n = I18n::factory();
     $this->i18n->loadFile($_SERVER['DOCUMENT_ROOT'] . BASE_PATH . APP_PATH . '/vendor/Phire/data/assets/i18n/' . $this->i18n->getLanguage() . '.xml');
     parent::__construct($request, $response, $project, $viewPath);
     $this->sess = Session::getInstance();
 }
 /**
  * Constructor method to instantiate the user controller object
  *
  * @param  Request  $request
  * @param  Response $response
  * @param  Project  $project
  * @param  string   $viewPath
  * @return self
  */
 public function __construct(Request $request = null, Response $response = null, Project $project = null, $viewPath = null)
 {
     // Create the session object and get the user type
     $this->sess = Session::getInstance();
     $this->type = $project->getService('acl')->getType();
     if (null === $viewPath) {
         $cfg = $project->module('Phire')->asArray();
         $viewPath = __DIR__ . '/../../../../view/phire';
         if (isset($cfg['view'])) {
             $class = get_class($this);
             if (is_array($cfg['view']) && isset($cfg['view'][$class])) {
                 $viewPath = $cfg['view'][$class];
             } else {
                 if (is_array($cfg['view']) && isset($cfg['view']['*'])) {
                     $viewPath = $cfg['view']['*'];
                 } else {
                     if (is_string($cfg['view'])) {
                         $viewPath = $cfg['view'];
                     }
                 }
             }
         }
         // If it is not a user, or a user globally logged into another area
         if (strtolower($this->type->type) != 'user' && !$this->type->global_access || substr($_SERVER['REQUEST_URI'], 0, strlen(BASE_PATH . APP_URI)) != BASE_PATH . APP_URI) {
             $site = Table\Sites::getSite();
             $theme = Table\Extensions::findBy(array('type' => 0, 'active' => 1), null, 1);
             $themePath = $site->document_root . $site->base_path . CONTENT_PATH . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $this->type->type;
             $activeThemePath = null;
             if (isset($theme->rows[0])) {
                 $activeThemePath = $site->document_root . $site->base_path . CONTENT_PATH . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $theme->rows[0]->name . DIRECTORY_SEPARATOR . $this->type->type;
             }
             if (null !== $activeThemePath && file_exists($activeThemePath)) {
                 $viewPath = $activeThemePath;
             } else {
                 if (file_exists($themePath)) {
                     $viewPath = $themePath;
                 }
             }
         }
     }
     // Set the correct base path and user URI based on user type
     if (get_called_class() == 'Phire\\Controller\\Phire\\IndexController') {
         $basePath = strtolower($this->type->type) != 'user' ? BASE_PATH . '/' . strtolower($this->type->type) : BASE_PATH . APP_URI;
         $request = new Request(null, $basePath);
     }
     parent::__construct($request, $response, $project, $viewPath);
 }
 /**
  * Constructor method to instantiate the groups controller object
  *
  * @param  Request  $request
  * @param  Response $response
  * @param  Project  $project
  * @param  string   $viewPath
  * @return self
  */
 public function __construct(Request $request = null, Response $response = null, Project $project = null, $viewPath = null)
 {
     if (null === $viewPath) {
         $cfg = $project->module('Phire')->asArray();
         $viewPath = __DIR__ . '/../../../../../view/phire/structure';
         if (isset($cfg['view'])) {
             $class = get_class($this);
             if (is_array($cfg['view']) && isset($cfg['view'][$class])) {
                 $viewPath = $cfg['view'][$class];
             } else {
                 if (is_array($cfg['view']) && isset($cfg['view']['*'])) {
                     $viewPath = $cfg['view']['*'];
                 } else {
                     if (is_string($cfg['view'])) {
                         $viewPath = $cfg['view'];
                     }
                 }
             }
         }
     }
     parent::__construct($request, $response, $project, $viewPath);
 }
Example #4
0
 public function testLoadModule()
 {
     $p = new Project(new Config(array('databases' => array('testdb' => Db::factory('Sqlite', array('database' => __DIR__ . '/../tmp/test.sqlite'))), 'defaultDb' => 'testdb')), null, new Router(array('Pop\\Mvc\\Controller' => new Controller())));
     $p->loadModule(array('Test' => new Config(array('some' => 'thing'))));
     $p->loadModule(array('Blah' => array('some' => 'thing')));
     $this->assertInstanceOf('Pop\\Config', $p->module('Test'));
     $this->assertInstanceOf('Pop\\Config', $p->module('Blah'));
 }