public function setSignUpSteps(array $stepsConfig)
 {
     $knownContexts = array(SignUpService::MULTIPLE_CENTER_SIGN_UP, SignUpService::SINGLE_CENTER_SIGN_UP);
     foreach ($stepsConfig as $_signUpContext => $_steps) {
         if (!\in_array($_signUpContext, $knownContexts)) {
             // unknown sign up context
             continue;
         }
         $parent = null;
         foreach ($_steps as $key => $v) {
             $_step = new SignUpStep();
             $_step->setLabel($v['label']);
             $_step->setRoute($v['route']);
             // keys in array will start in 0
             $_step->setStepNumber($key + 1);
             $_step->setSub(isset($v['sub']) ? $v['sub'] : false);
             // if this step is a sub step, set the parent to the recent $parent
             // NOTE: this implementation is restricted to the arrangement in the steps configuration
             if ($_step->isSub()) {
                 $_step->setParent($parent);
             } else {
                 // step is not a sub, set as the current parent
                 $parent = $_step;
             }
             $this->signUpSteps[$_signUpContext][] = $_step;
             $this->signUpStepsByRoute[$_signUpContext][$_step->getRoute()] = $_step;
         }
     }
 }
 /**
  * Setting up profile of multiple center institution
  *
  * @param Request $request
  */
 private function setupProfileMultipleCenter(Request $request)
 {
     // get the current step by this route
     $this->currentSignUpStep = $this->signUpService->getMultipleCenterSignUpStepByRoute($this->request->attributes->get('_route'));
     $this->get('services.contact_detail')->initializeContactDetails($this->institution, array(ContactDetailTypes::PHONE));
     $form = $this->createForm(new InstitutionProfileFormType(), $this->institution, array(InstitutionProfileFormType::OPTION_BUBBLE_ALL_ERRORS => false));
     if ($request->isMethod('POST')) {
         $formRequestData = $request->get($form->getName());
         if (isset($formRequestData['medicalProviderGroups'])) {
             // we always expect 1 medical provider group
             // if it is empty remove it from the array
             if (isset($formRequestData['medicalProviderGroups'][0]) && '' == trim($formRequestData['medicalProviderGroups'][0])) {
                 unset($formRequestData['medicalProviderGroups'][0]);
             } else {
                 $formRequestData['medicalProviderGroups'][0] = str_replace(array("\\'", '\\"'), array("'", '"'), $formRequestData['medicalProviderGroups'][0]);
             }
         }
         // Check If Custom State
         if (!$formRequestData['state'] && ($stateName = $request->get('custom_state'))) {
             $stateData = array('name' => $stateName, 'geoCountry' => $formRequestData['country'], 'institutionId' => $this->institution->getId());
             if ($state = $this->get('services.location')->addNewState($stateData)) {
                 $formRequestData['state'] = $state->getId();
             }
         }
         // Check If Custom City
         if (!(int) $formRequestData['city'] && ($cityName = $request->get('custom_city'))) {
             $cityData = array('name' => $cityName, 'geoState' => $formRequestData['state'], 'geoCountry' => $formRequestData['country'], 'institutionId' => $this->institution->getId());
             if ($city = $this->get('services.location')->addNewCity($cityData)) {
                 $formRequestData['city'] = $city->getId();
             }
         }
         $form->bind($formRequestData);
         if ($form->isValid()) {
             $this->get('services.contact_detail')->removeInvalidContactDetails($this->institution);
             $em = $this->getDoctrine()->getManager();
             $em->persist($this->institution);
             // set sign up status to current step number
             $this->_updateInstitutionSignUpStepStatus($this->currentSignUpStep);
             $form->getData()->setSignupStepStatus($this->currentSignUpStep->getStepNumber());
             $this->signUpService->completeProfileOfInstitutionWithMultipleCenter($form->getData());
             $this->get('services.institution_property')->addPropertiesForInstitution($this->institution, $form['services']->getData(), $form['awards']->getData());
             $request->getSession()->setFlash('success', "<b>Congratulations!</b> You have setup your Hospital's profile.");
             //set flash message
             $redirectUrl = $this->generateUrl($this->signUpService->getMultipleCenterSignUpNextStep($this->currentSignUpStep)->getRoute());
             // TODO: Update this when we have formulated a strategy for our event system
             // We can't use InstitutionBundleEvents; we don't know the consequences of the event firing up other listeners.
             $this->get('event_dispatcher')->dispatch(MailerBundleEvents::NOTIFICATIONS_HOSPITAL_CREATED, new GenericEvent($this->institution));
             return $this->redirect($redirectUrl);
         } else {
             $request->getSession()->setFlash('error', 'We need you to correct some of your input. Please check the fields in red.');
         }
     }
     return $this->render('InstitutionBundle:SignUp:setupProfile.multipleCenter.html.twig', array('form' => $form->createView(), 'medicalProvidersJSON' => $this->getMedicalProviderGroupJSON()));
 }