|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Copyright © 2021 ExacTI Technology Solutions. All rights reserved.
|
|
|
|
* GPLv3 General License.
|
|
|
|
* https://exacti.com.br
|
|
|
|
* Phacil PHP Framework - https://github.com/exacti/phacil-framework
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Phacil\Framework\Traits;
|
|
|
|
|
|
|
|
use Phacil\Framework\Config;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Trait for the Action class
|
|
|
|
*
|
|
|
|
* Code reused in ActionSystem class
|
|
|
|
*
|
|
|
|
* @see \Phacil\Framework\Interfaces\Action
|
|
|
|
*/
|
|
|
|
trait Action {
|
|
|
|
|
|
|
|
/**
|
Controller child exception, Log, Response and Login
Action PHPDoc improvements, Controller child exception, Log new functions (getpath, getfilename, head and tail), log class check dir and creates if not exists, Response redirect improvement, Controller redirect function use the response redirect class, login interface documentation, login doc
3 years ago
|
|
|
* Storage the file to be loaded
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $file;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $route;
|
|
|
|
|
|
|
|
/**
|
Controller child exception, Log, Response and Login
Action PHPDoc improvements, Controller child exception, Log new functions (getpath, getfilename, head and tail), log class check dir and creates if not exists, Response redirect improvement, Controller redirect function use the response redirect class, login interface documentation, login doc
3 years ago
|
|
|
* Storage the class to be loaded
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $class;
|
|
|
|
|
|
|
|
/**
|
Controller child exception, Log, Response and Login
Action PHPDoc improvements, Controller child exception, Log new functions (getpath, getfilename, head and tail), log class check dir and creates if not exists, Response redirect improvement, Controller redirect function use the response redirect class, login interface documentation, login doc
3 years ago
|
|
|
* Storage the method to be called
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $method;
|
|
|
|
|
|
|
|
/**
|
Controller child exception, Log, Response and Login
Action PHPDoc improvements, Controller child exception, Log new functions (getpath, getfilename, head and tail), log class check dir and creates if not exists, Response redirect improvement, Controller redirect function use the response redirect class, login interface documentation, login doc
3 years ago
|
|
|
* Storage the method args
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $args = array();
|
|
|
|
|
|
|
|
/**
|
Controller child exception, Log, Response and Login
Action PHPDoc improvements, Controller child exception, Log new functions (getpath, getfilename, head and tail), log class check dir and creates if not exists, Response redirect improvement, Controller redirect function use the response redirect class, login interface documentation, login doc
3 years ago
|
|
|
* Storage the all possible controller classes
|
|
|
|
*
|
Controller child exception, Log, Response and Login
Action PHPDoc improvements, Controller child exception, Log new functions (getpath, getfilename, head and tail), log class check dir and creates if not exists, Response redirect improvement, Controller redirect function use the response redirect class, login interface documentation, login doc
3 years ago
|
|
|
* @since 2.0.0
|
|
|
|
* @var (string[]|string|array|null)[]
|
|
|
|
*/
|
|
|
|
private $classAlt = [];
|
|
|
|
|
|
|
|
/** @inheritdoc */
|
|
|
|
public function getFile() {
|
|
|
|
return $this->file;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
Controller child exception, Log, Response and Login
Action PHPDoc improvements, Controller child exception, Log new functions (getpath, getfilename, head and tail), log class check dir and creates if not exists, Response redirect improvement, Controller redirect function use the response redirect class, login interface documentation, login doc
3 years ago
|
|
|
* @deprecated 2.0.0 This method return only legacy class. Use getClassAlt instead.
|
|
|
|
* @inheritdoc */
|
|
|
|
public function getClass() {
|
|
|
|
return $this->class;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function mountClass($namespace, $class, $withPrefix = true) {
|
|
|
|
return ($withPrefix && Config::NAMESPACE_PREFIX() ? Config::NAMESPACE_PREFIX()."\\" : "").str_replace("/", "\\", (string) $namespace)."Controller\\".(string) $class;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function setClass($class) {
|
|
|
|
$this->class = $class;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @inheritdoc */
|
|
|
|
public function getClassAlt() {
|
|
|
|
return $this->classAlt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @inheritdoc */
|
|
|
|
public function getMethod() {
|
|
|
|
return $this->method;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @inheritdoc */
|
|
|
|
public function getArgs() {
|
|
|
|
return $this->args;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRoute() {
|
|
|
|
return $this->route;
|
|
|
|
}
|
|
|
|
}
|