6
How do I access variables from another controller
?
For example:
I have a controller X
, and in action index
, I create a variable (or a constant).
Of controller Y
, I want to access the value of the variable (or constant) of controller X
.
Is it possible to do that?
Remembering that every action of each controller
, in my application, will have a variable that should be accessible from another controller
.
Controller Exemplox
class ExemploXController
{
$dependencias = array("index","listar");
public function index()
{
echo "Index";
}
public function funcaoX()
{
echo "Funcão X";
}
public function listar()
{
echo "listando";
}
}
Controller Exemploy
class ExemploYController
{
$dependencias = array("index","atualizar");
public function index()
{
//pegar o valor da variável $dependencias da controller ExemploXController
$dependency[] = ExemploXController->dependencias;
}
public function funcaoY()
{
echo "Funcão Y";
}
public function atualizar()
{
echo "atualizar";
}
}
Can you give a simple but concrete example? What you are asking for you can probably do otherwise.
– bfavaretto
Okay. I added. How would I do that?
– morphinduction