public function createAction()
 {
     $usersData = $this->serviceQueryPlugin->getUsers();
     if ($this->request->isPost()) {
         $submitedData = (array) $this->request->getPost();
         $serviceEntity = new Service();
         if (!empty($submitedData["parent"])) {
             $parent = $this->doctrineService->find('Application\\Entity\\Service', $submitedData["parent"]);
             $serviceEntity->setParent($parent);
         }
         $this->doctrineService->persist($serviceEntity);
         $languages = $this->doctrineService->getRepository('Application\\Entity\\Language')->findAll();
         foreach ($languages as $lang) {
             $serviceTemp = new ServiceLang();
             $serviceTemp->setEnable(isset($submitedData["enable"][$lang->getCode()]) ? 1 : 0);
             $serviceTemp->setName($submitedData["name"][$lang->getCode()]);
             $serviceTemp->setDescription($submitedData["description"][$lang->getCode()]);
             $serviceTemp->setOrder(0);
             $serviceTemp->setLanguage($lang);
             $serviceTemp->setService($serviceEntity);
             $this->doctrineService->persist($serviceTemp);
         }
         $this->serviceQueryPlugin->updateWorkAt($serviceEntity, isset($submitedData["selectedUsers"]) ? $submitedData["selectedUsers"] : array(), $usersData["selected"]);
         $this->doctrineService->flush();
         $this->layout()->message = ['type' => 'success', 'text' => 'new user  created successfully.'];
     }
     $usersData = $this->serviceQueryPlugin->getUsers();
     $services = $this->serviceUiGeneratorPlugin->getForTree($this->language->getId());
     return $this->serviceUiGeneratorPlugin->getCreateServiceForm($services, $usersData, $this->language->getCode());
 }
 public function createAction()
 {
     if ($this->request->isPost()) {
         $submitedData = (array) $this->request->getPost();
         $serviceEntity = new Service();
         if (!empty($submitedData["parent"])) {
             $parent = $this->doctrineService->find('Application\\Entity\\Service', $submitedData["parent"]);
             $serviceEntity->setParent($parent);
         }
         $this->doctrineService->persist($serviceEntity);
         $languages = $this->doctrineService->getRepository('Application\\Entity\\Language')->findAll();
         foreach ($languages as $lang) {
             $attributes = json_decode($lang->getAttribute());
             $serviceTemp = new ServiceLang();
             $serviceTemp->setEnable(isset($submitedData["enable"][$attributes->code]) ? 1 : 0);
             $serviceTemp->setName($submitedData["name"][$attributes->code]);
             $serviceTemp->setDescription($submitedData["description"][$attributes->code]);
             $serviceTemp->setOrder(0);
             $serviceTemp->setLanguage($lang);
             $serviceTemp->setService($serviceEntity);
             $this->doctrineService->persist($serviceTemp);
         }
         $this->doctrineService->flush();
         $this->layout()->message = ['type' => 'success', 'text' => 'new user is created successfully.'];
     }
     $services = $this->getForTree();
     return $this->getCreateServiceForm($services);
 }