public function createServiceDescribe(array $service)
 {
     $em = $this->doctrineBoot->getEntityManager();
     $repo = $em->getRepository(ServiceDescribe::class);
     $id = Uuid::uuid5(Uuid::NAMESPACE_OID, $service['name'])->toString();
     $plans = [];
     foreach ($service['plans'] as $plan) {
         $plans[] = $this->createPlan($plan);
     }
     $bindable = !isset($service['bindable']) || $service['bindable'] ? true : false;
     $planUpdateable = !isset($service['plan_updateable']) || $service['plan_updateable'] ? true : false;
     $requires = !isset($service['requires']) ? [] : $service['requires'];
     $tags = !isset($service['tags']) ? [] : $service['tags'];
     $serviceDescribe = $repo->find($id);
     if ($serviceDescribe !== null) {
         $serviceDescribe->setPlans($plans);
         $serviceDescribe->setBindable($bindable);
     } else {
         $serviceDescribe = new ServiceDescribe($id, $service['name'], $service['description'], $plans, $bindable);
     }
     if (isset($service['dashboard_client'])) {
         $serviceDescribe->setDashboard($this->createDashboard($service['dashboard_client']));
     }
     if (isset($service['metadata'])) {
         $serviceDescribe->setMetadata($this->createMetadata($service['metadata']));
     }
     $serviceDescribe->setPlanUpdateable($planUpdateable);
     $serviceDescribe->setRequires($requires);
     $serviceDescribe->setTags($tags);
     $em->persist($serviceDescribe);
     $em->flush();
 }
 public function getServiceDescribeAsArray(ServiceDescribe $serviceDescribe)
 {
     $service = [];
     $service['id'] = $serviceDescribe->getId();
     $service['name'] = $serviceDescribe->getName();
     $service['description'] = $serviceDescribe->getDescription();
     $service['plan_updateable'] = $serviceDescribe->isPlanUpdateable();
     $service['requires'] = $serviceDescribe->getRequires();
     $service['tags'] = $serviceDescribe->getTags();
     $service['plans'] = [];
     foreach ($serviceDescribe->getPlans() as $plan) {
         $service['plans'][] = $this->getPlanAsArray($plan);
     }
     if ($serviceDescribe->getMetadata() !== null) {
         $service['metadata'] = $this->getMetadataServiceDescribeAsArray($serviceDescribe->getMetadata());
     }
     if ($serviceDescribe->getDashboard() === null) {
         $services['services'][] = $service;
         return $service;
     }
     $service['dashboard_client']['id'] = $serviceDescribe->getDashboard()->getId();
     $service['dashboard_client']['secret'] = $serviceDescribe->getDashboard()->getSecret();
     $service['dashboard_client']['redirect_uri'] = $serviceDescribe->getDashboard()->getRedirectUri();
     return $service;
 }