Exemple #1
0
 protected function configureFormFields(FormMapper $formMapper)
 {
     $translator = $this->getConfigurationPool()->getContainer()->get("translator");
     $lTranslator = function ($input, $transDomain) use($translator) {
         $output = [];
         foreach ($input as $key => $value) {
             $output[$key] = $translator->trans($value, [], $transDomain);
         }
         return $output;
     };
     $tradeTypes = $lTranslator(Estate::getTradeTypes(), "trade_types");
     $districts = $lTranslator(Estate::getDistricts(), "districts");
     $estateTypeQuery = $this->modelManager->getEntityManager('AppBundle\\Entity\\EstateType')->createQueryBuilder()->select("estateType")->from('AppBundle\\Entity\\EstateType', 'estateType')->where("estateType.parent IS NOT NULL");
     $formMapper->with("Нерухомість - Локалізований контент")->add("translations", "a2lix_translations_gedmo", ["locales" => ['ua', 'en'], "label" => FALSE, "translatable_class" => 'AppBundle\\Entity\\Estate', "required" => TRUE, "fields" => ["title" => ["locale_options" => ["ua" => ["required" => FALSE, "label" => "Назва об'єкту"], "en" => ["required" => FALSE, "label" => "Estate title"]]], "address" => ["locale_options" => ["ua" => ["label" => "Точна адреса об'єкту"], "en" => ["required" => FALSE, "label" => "Exact property address"]]], "description" => ["locale_options" => ['ua' => ['label' => 'Опис', 'field_type' => 'ckeditor', 'config_name' => 'base_config'], 'en' => ["required" => FALSE, 'label' => 'Description', 'field_type' => 'ckeditor', 'config_name' => 'base_config']]], 'slug' => ['display' => FALSE]]])->end()->with("Нерухомість - Ручне введення координат")->add("coordinatesManualLat", "text", ['required' => FALSE, 'label' => "Широта"])->add("coordinatesManualLng", "text", ['required' => FALSE, 'label' => "Довгота"])->end()->with("Нерухомість - Загальні дані")->add("code", "text", ["label" => "ID"])->add("tradeType", "choice", ["label" => "Тип транзакції", "placeholder" => "Оберіть тип транзакції...", "choices" => $tradeTypes])->add("estateType", NULL, ["label" => "Тип нерухомості", "required" => TRUE, "placeholder" => "Оберіть тип нерухомості...", "class" => 'AppBundle\\Entity\\EstateType', "query_builder" => $estateTypeQuery], ['edit' => 'standard'])->add("district", "choice", ["label" => "Район", "placeholder" => "Оберіть район...", "choices" => $districts])->add("space", "number", ["label" => "Площа", "precision" => 2])->add("spacePlot", "number", ["required" => FALSE, "label" => "Площа ділянки", "precision" => 2])->add("priceUAH", "number", ["required" => FALSE, "label" => "Ціна (UAH)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add("priceUSD", "number", ["label" => "Ціна (USD)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add("pricePerSquareUAH", "number", ["required" => FALSE, "label" => "Ціна за м2 (UAH)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add("pricePerSquareUSD", "number", ["required" => FALSE, "label" => "Ціна за м2 (USD)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add('isActive', 'checkbox', ["required" => FALSE, "label" => "Відображається"])->end()->with("Нерухомість - Особливості")->add('estateFeatures', 'sonata_type_admin', ['label' => FALSE, 'delete' => FALSE])->end()->with("Нерухомість - Характеристики")->add('estateAttribute', 'sonata_type_collection', ['label' => FALSE, 'by_reference' => FALSE, 'btn_add' => "Додати характеристику"], ['edit' => 'inline', 'inline' => 'table'])->end()->with("Нерухомість - Фотографії")->add('estatePhoto', 'sonata_type_collection', ['required' => TRUE, 'label' => "Керування зображеннями", 'by_reference' => FALSE, 'btn_add' => "Додати зображення"], ['edit' => 'inline', 'inline' => 'table', 'sortable' => 'position'])->end();
 }
 public function availableDistricts(array $estates)
 {
     $availableDistricts = [];
     $existingDistricts = Estate::getDistricts();
     foreach ($estates as $estate) {
         if ($estate instanceof Estate) {
             if (!in_array($estate->getDistrict(), $availableDistricts, TRUE) && !empty($existingDistricts[$estate->getDistrict()])) {
                 $availableDistricts[$estate->getDistrict()] = $existingDistricts[$estate->getDistrict()];
             }
         }
     }
     return $availableDistricts;
 }
Exemple #3
0
 protected function validateDistricts(array $districts)
 {
     $existingDistricts = array_keys(Estate::getDistricts());
     foreach ($districts as $district) {
         if (!in_array($district, $existingDistricts, TRUE)) {
             return FALSE;
         }
     }
     return TRUE;
 }