Пример #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();
 }
Пример #2
0
 /**
  * Return the name of exposed direct Action.
  * 
  * @return string
  */
 public function getActionName()
 {
     return str_replace('Controller', '', $this->reflection->getShortName());
 }