Its a bad practice to call a function from one to another controller. You have two options:
1) Use a BaseController
which has the common functions which other controllers can reuse, by extending the BaseController
.
class MembershipController extends ...
{
public function checkMembership()
{
return ...
}
}
class UserController extends MembershipController
{
public function indexAction()
{
$this->checkMembership();
}
}
2) Remove the method from MembershipController
and place it in a Model
, Library
or a Helper
.
class MembershipHelper
{
public static function checkMembership()
{
return ...
}
}
class UserController extends MembershipController
{
public function indexAction()
{
\Helpers\MembershipHelper::checkMembership();
}
}
Of course namespaces and class names are just for example. You will have to modify according to your project structure.