Пример #1
0
 public function availableFeatures($estates)
 {
     $availableFeatures = [];
     $existingEstateFeatures = EstateFeatures::getEstateFeatures();
     foreach ($estates as $estate) {
         if ($estate instanceof Estate) {
             $estateFeatures = $estate->getEstateFeatures();
             if ($estateFeatures instanceof EstateFeatures) {
                 foreach ($existingEstateFeatures as $feature) {
                     if ($estateFeatures->getFeatureByName($feature)) {
                         $availableFeatures[$feature] = $estateFeatures->getFeatureByName($feature);
                     }
                 }
             }
         }
     }
     return $availableFeatures;
 }
Пример #2
0
 /**
  * Set estateFeatures
  *
  * @param \AppBundle\Entity\EstateFeatures $estateFeatures
  * @return Estate
  */
 public function setEstateFeatures(\AppBundle\Entity\EstateFeatures $estateFeatures = null)
 {
     if ($estateFeatures instanceof EstateFeatures) {
         $estateFeatures->setEstate($this);
     }
     $this->estateFeatures = $estateFeatures;
     return $this;
 }
Пример #3
0
 protected function validateFeatures($features)
 {
     $existingEstateFeatures = EstateFeatures::getEstateFeatures();
     foreach ($features as $feature => $value) {
         if (!in_array($feature, $existingEstateFeatures, TRUE)) {
             return FALSE;
         }
         if (!in_array($value, ['yes', 'no'], TRUE)) {
             return FALSE;
         }
     }
     return TRUE;
 }