If your Service Layer is similar to a Model file, then add below lines of code to the Service Layer class file -
protected $router;
protected $request;
public function setRouter($router = null) {
$this->router = $router;
}
public function getRouter() {
return $this->router;
}
public function setRequest($request = null) {
$this->request = $request;
}
public function getRequest() {
return $this->request;
}
Now from the Controller class, when your using the Service Layer class, do similar to the following - (It may not be exactly the same but you will get the idea)
Controller Class -
$service_layer_classname = new ServiceLayer_ClassName();
$service_layer_classname->setRequest($this->getRequest());
$service_layer_classname->setRouter($this->getEvent()->getRouter());
In this way, you can use similar functions to get the Controller based access in the Service Layer Class.
OR
in a short but not-recommended way, you can just pass the whole controller object (i.e. $this) to the Service Layer class and access all the functions. Obviously it is not a good programming approach.
I hope it helps.