Hello everyone:
I’m developing a application for website and mobile app; I have created a controller:
namespace App\Controller
class OrdersController extends AppController
{
function placeOrder()
{
//generate order business
return $this->response();
}
}
Now I need to create a api controller
namspace App\Api\Controller;
class OrdersController extends AppController
{
function placeOrder()
{
//generate order business
return new JsonResponse();
}
}
You know App\Controller\OrdersController::placeOrder()
and App\Api\Controller::placeOrder
are very similar. I just need to copy my code. however copy code is stupid.
do you have some good idea to avod copy code?