headers->get('x-auth-token'); $security->isGranted('MAESTRO_PROJECT_PROJECTS_DELETE', $token); if (!$params->get('workflow_enabled')) { $body = [ 'type' => 'error', 'key' => 'workflow_enabled', 'method' => 'delete', 'data' => '', ]; return $respond->statusUnauthorized()->createBody($body)->respond(); } // $profileQuery->getProfileFromToken($request->headers->get('x-auth-token')); $config = json_decode($request->getContent(), false); if (!$config->configuration) { $body = [ 'type' => 'error', 'key' => 'config', 'method' => 'delete', 'data' => 'Please provide a configuration !', ]; return $respond->statusUnprocessableEntity()->createBody($body)->respond(); } if (!$config->places) { $body = [ 'type' => 'error', 'key' => 'config', 'method' => 'delete', 'data' => 'Please provide a places !', ]; return $respond->statusUnprocessableEntity()->createBody($body)->respond(); } if (!$config->transitions) { $body = [ 'type' => 'error', 'key' => 'config', 'method' => 'delete', 'data' => 'Please provide a transitions !', ]; return $respond->statusUnprocessableEntity()->createBody($body)->respond(); } $configuration = new ConfigurationCreateView( $config->configuration->name, $config->configuration->id ); $places = []; foreach ($config->places as $place) { $places[] = new PlaceProjectCreateView( $place->id, $place->name, $place->color, $place->default, $place->date_fin, $place->users, $place->blockPictures, $place->blockTexts, false ); } $transitions = []; foreach ($config->transitions as $transition) { $transitions[] = new TransitionCreateView( $transition->name, $transition->position, $transition->debut, $transition->fin, $transition->users, $transition->commands ); } $projectPlace->removePlace($id); $projectPlace->changePlaceKey($configuration, $places); $ids = []; if ($config->configuration->id) { $projectIds = $project->listIdByWorkflowId($config->configuration->id); $ids = []; foreach ($projectIds as $projectId) { $ids[] = $projectId->id; } } $configurationCreate = $configurationQuery->create($configuration, $places, $transitions, $config->module); if ($configurationCreate && !empty($ids)) { $providerPlace->firstPlace($ids, $config->configuration->id); } if (!$configurationCreate) { $body = [ 'type' => 'error', 'key' => 'config', 'method' => 'delete', 'data' => '', ]; $respond->statusUnauthorized(); } else { $body = [ 'type' => 'error', 'key' => 'config', 'method' => 'delete', 'data' => $configurationCreate, ]; $respond->statusOK(); } return $respond->createBody($body)->respond(); } }