Hello ! I am very new to Laminas and facing a simple problem. Currently I am loading handle()
from class SearchInquiryHandler
when routed as $app->post('/api/search/inquiry', App\Handler\SearchInquiryHandler::class, 'api.search.inquiry');
from routes.php
. I want to load another method from class SearchInquiryHandler
but no luck. Here is the basic script. yes i have a SearchInquiryHandlerFactory.php
and ConfigProvider.php
here is my routes.php
this is loading the handle()
inside `SearchInquiryHandler
$app->post('/api/search/inquiry', App\Handler\SearchInquiryHandler::class, 'api.search.inquiry');
Here is my SearchInquiryHandler.php
class SearchInquiryHandler implements RequestHandlerInterface {
public function __construct(##SOME CODE HERE##) {
<!--SOME CODE HERE-->
}
public function handle(ServerRequestInterface $request) : ResponseInterface
{
return new JsonResponse(['ack' => 'GETTING RESPONSE']);
}
public function loadThisMethod(ServerRequestInterface $request) : ResponseInterface
{
return new JsonResponse(['ack' => 'want to load this method']);
}
}
How can i route to 'SearchInquiryHandler:loadThisMethod'
with different route definition loading same class like
$app->post('/api/search/loadthismethod', App\Handler\SearchInquiryHandler::class, 'api.search.inquiry');
I am thinking like if i can detect routing URL inside handle()
and with proper checking i can load loadthismethod()
inside handle()
method something like this may work
public function handle(ServerRequestInterface $request) : ResponseInterface
{
$uri = $request->getUri();
$path = $uri->getPath();
if($path!='/api/search/inquiry'){
$this->loadthismethod();
}
}
Any guidance will be hugely appreciated