Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
32 / 32 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| DepartmentAddCluster | |
100.00% |
32 / 32 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
32 / 32 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package 115Mandant |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsadmin; |
| 9 | |
| 10 | use BO\Zmsentities\Cluster as Entity; |
| 11 | use BO\Mellon\Validator; |
| 12 | |
| 13 | class DepartmentAddCluster extends BaseController |
| 14 | { |
| 15 | /** |
| 16 | * @return String |
| 17 | */ |
| 18 | public function readResponse( |
| 19 | \Psr\Http\Message\RequestInterface $request, |
| 20 | \Psr\Http\Message\ResponseInterface $response, |
| 21 | array $args |
| 22 | ) { |
| 23 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); |
| 24 | $departmentId = Validator::value($args['departmentId'])->isNumber()->getValue(); |
| 25 | $department = \App::$http |
| 26 | ->readGetResult('/department/' . $departmentId . '/', ['resolveReferences' => 2])->getEntity(); |
| 27 | $organisation = \App::$http->readGetResult('/department/' . $departmentId . '/organisation/')->getEntity(); |
| 28 | $input = $request->getParsedBody(); |
| 29 | |
| 30 | if (is_array($input) && array_key_exists('save', $input)) { |
| 31 | $entity = (new Entity($input))->withCleanedUpFormData(); |
| 32 | $entity->scopes = (new \BO\Zmsentities\Collection\ScopeList($entity->scopes))->withUniqueScopes(); |
| 33 | $entity = \App::$http |
| 34 | ->readPostResult('/department/' . $department->id . '/cluster/', $entity) |
| 35 | ->getEntity(); |
| 36 | (new Helper\FileUploader($request, 'uploadCallDisplayImage'))->writeUploadToCluster($entity->id); |
| 37 | return \BO\Slim\Render::redirect( |
| 38 | 'cluster', |
| 39 | array( |
| 40 | 'departmentId' => $department->id, |
| 41 | 'clusterId' => $entity->id |
| 42 | ), |
| 43 | array( |
| 44 | 'success' => 'cluster_created' |
| 45 | ) |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | return \BO\Slim\Render::withHtml($response, 'page/cluster.twig', array( |
| 50 | 'title' => 'Cluster', |
| 51 | 'action' => 'add', |
| 52 | 'menuActive' => 'owner', |
| 53 | 'workstation' => $workstation, |
| 54 | 'scopeList' => $department->getScopeList()->withUniqueScopes(), |
| 55 | 'organisation' => $organisation, |
| 56 | 'department' => $department |
| 57 | )); |
| 58 | } |
| 59 | } |