Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ViewJobsAsGuestRequest{
- private $category;
- private $searchstring;
- private $limit;
- private $offset;
- public function __construct($searchstring,$category,$limit,$offset){
- //setting properties
- }
- //getters for properties
- }
- class ViewJobsAsGuestInteraction{
- public function __construct(JobRepository $jobRepository){}
- public function invoke(ViewJobsAsGuestRequest $request){
- $jobEntities = $this->jobRepository->findManyByCategory($request->getCategory());
- $view = new JobListView();
- foreach($jobEntities as $jobEntity){
- $view->addJob($job); //maybe dont add the complete job, just view properties required for the view in this usecase
- }
- return new ViewJobsAsGuestResponse($view);
- }
- }
- class JobsController{
- public function before(){
- //create instances of Repositories and Services or other stuffs
- }
- public function viewAction(Request $request){
- $viewJobsAsGuestRequest = new ViewJobsAsGuestRequest($request->get('category')); //convert HTTP Request to APplication request
- $viewJobsAsGuestInteraction = new ViewJobsAsGuestInteraction($this->mysqlJobRepository);
- $viewJobsAsGuestResponse = $viewJobsAsGuestInteraction->invoke($viewJobsAsGuestRequest);
- $responseBody = $this->presenter->render('joblist.mustache',$viewJobsAsGuestResponse->getJobListView()); //get the view model from response and render it with template
- return new Response($responseBody); //set the parset HTML code as HTTP Response
- }
- public function after(){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment