Ejemplo n.º 1
0
 /**
  * final construct so no other class can override it
  * To load something in the constructor, use init()
  *
  * @params array $segments - extra segments from that can be accessed with getParams()
  */
 public final function __construct(array $segments = [])
 {
     /**
      * Built variables based on the controller
      */
     $this->reflection = new ReflectionClass(get_called_class());
     $namespace = $this->reflection->getNamespaceName();
     $nsArr = explode("\\", $namespace);
     $this->moduleName = current(array_splice($nsArr, -2));
     $this->namespace = $this->reflection->getName();
     $this->controllerName = $this->reflection->getShortName();
     $this->controllerNamespace = $namespace;
     $this->moduleDir = dirname(dirname($this->reflection->getFileName()));
     $this->applicationDir = dirname($this->moduleDir);
     $this->moduleNamespace = $this->getParentNamespace($namespace);
     $this->segments = array_values(array_filter($segments));
     $this->init();
 }