| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_New_View_Dispatcher |
| 4 |
{ |
| 5 |
public function __construct( |
| 6 |
HC3_Hooks $hooks, |
| 7 |
|
| 8 |
HC3_Request $request, |
| 9 |
|
| 10 |
SH4_App_Query $appQuery, |
| 11 |
SH4_Employees_Query $employeesQuery, |
| 12 |
SH4_New_Query $newQuery |
| 13 |
) |
| 14 |
{ |
| 15 |
$this->self = $hooks->wrap( $this ); |
| 16 |
$this->request = $request; |
| 17 |
|
| 18 |
$this->appQuery = $hooks->wrap( $appQuery ); |
| 19 |
$this->employeesQuery = $hooks->wrap( $employeesQuery ); |
| 20 |
$this->newQuery = $hooks->wrap( $newQuery ); |
| 21 |
|
| 22 |
} |
| 23 |
|
| 24 |
public function render() |
| 25 |
{ |
| 26 |
$to = $this->getTo(); |
| 27 |
$params = $this->request->getParams(); |
| 28 |
if( $params ){ |
| 29 |
$to = array( $to, $params ); |
| 30 |
} |
| 31 |
|
| 32 |
$return = array( $to, NULL ); |
| 33 |
return $return; |
| 34 |
} |
| 35 |
|
| 36 |
protected function getTo() |
| 37 |
{ |
| 38 |
$return = NULL; |
| 39 |
$params = $this->request->getParams(); |
| 40 |
|
| 41 |
if( ! (array_key_exists('calendar', $params) && array_key_exists('shifttype', $params)) ){ |
| 42 |
$return = 'new/calendar'; |
| 43 |
return $return; |
| 44 |
} |
| 45 |
|
| 46 |
if( ! array_key_exists('date', $params) ){ |
| 47 |
$return = 'new/date'; |
| 48 |
return $return; |
| 49 |
} |
| 50 |
|
| 51 |
if( ! array_key_exists('employee', $params) ){ |
| 52 |
$return = 'new/employee'; |
| 53 |
return $return; |
| 54 |
} |
| 55 |
|
| 56 |
if( ! $return ){ |
| 57 |
$return = 'new/confirm'; |
| 58 |
return $return; |
| 59 |
} |
| 60 |
} |
| 61 |
} |