public function createInstitutionMedicalCenterPropertyByName($propertyTypeName, Institution $institution = null, InstitutionMedicalCenter $center)
 {
     $propertyType = $this->getAvailablePropertyType($propertyTypeName);
     $property = new InstitutionMedicalCenterProperty();
     $property->setInstitution($institution);
     $property->setInstitutionMedicalCenter($center);
     $property->setInstitutionPropertyType($propertyType);
     return $property;
 }
 public function __construct(InstitutionMedicalCenterProperty $imcProperty)
 {
     $this->parent = $imcProperty->getInstitutionPropertyType()->getDataType()->getFormField();
     $this->imcProperty = $imcProperty;
 }
 public function addPropertyForInstitutionMedicalCenterByType(Institution $institution, $properties = array(), $propertyTypeName, InstitutionMedicalCenter $institutionMedicalCenter)
 {
     $ids = array();
     $propertyType = $this->getAvailablePropertyType($propertyTypeName);
     $currentProperties = $this->propertyRepository->getPropertyValues($propertyType, $institutionMedicalCenter);
     foreach ($currentProperties as $property) {
         $ids[$property->getValue()] = $property->getExtraValue();
     }
     $this->removeInstitutionMedicalCenterPropertiesByPropertyType($propertyTypeName, $institutionMedicalCenter);
     $em = $this->doctrine->getManager();
     if (empty($properties)) {
         return;
     }
     //TODO: avoid the multiple inserts or check if doctrine will already optimize the queries
     foreach ($properties as $property) {
         $variableName = 'property' . $property;
         $variableName = new InstitutionMedicalCenterProperty();
         $variableName->setInstitution($institution);
         $variableName->setInstitutionMedicalCenter($institutionMedicalCenter);
         $variableName->setInstitutionPropertyType($propertyType);
         if (array_key_exists($property, $ids)) {
             //check if id exist already
             $variableName->setExtraValue($ids[$property]);
             // set ExtraValue
         }
         $variableName->setValue($property);
         $em->persist($variableName);
     }
     $em->flush();
     return;
 }