private function createIntegrationSystem($systemId, $system, IntegrationConfig $config) { $koalamonSystem = $this->getDoctrine()->getRepository('KoalamonIncidentDashboardBundle:System')->find($systemId); if ($koalamonSystem->getProject() != $this->getProject()) { return new JsonResponse(['status' => 'failure', 'message' => 'You tried to store a system from another project.']); } $integrationSystem = new IntegrationSystem(); $integrationSystem->setSystem($koalamonSystem); $integrationSystem->setIntegration($this->getIntegrationIdentifier()); $integrationSystem->setIntegrationConfig($config); if (array_key_exists('options', $system)) { $integrationSystem->setOptions($system['options']); } if (array_key_exists('inherit', $system)) { $integrationSystem->setInherit(true); } else { $integrationSystem->setInherit(false); } return $integrationSystem; }