Пример #1
0
 /**
  * @deprecated
  */
 protected function saveAttribute($attributeValue, $passedValue = false)
 {
     $controller = $this->getController();
     $orm = \Database::connection()->getEntityManager();
     $genericValue = $orm->find('Concrete\\Core\\Entity\\Attribute\\Value\\Value\\Value', $attributeValue->getAttributeValueID());
     if (is_object($genericValue)) {
         // delete the attribute value value
         $legacyValue = new LegacyValue();
         $legacyValue->setAttributeKey($this->legacyAttributeKey);
         $legacyValue->setGenericValue($genericValue);
         $valueValue = $legacyValue->getValueObject();
         if (is_object($valueValue)) {
             $orm->remove($valueValue);
         }
         $orm->flush();
     }
     if ($passedValue) {
         $value = $controller->createAttributeValue($passedValue);
     } else {
         $value = $controller->createAttributeValueFromRequest();
     }
     /**
      * @var $value AbstractValue
      */
     if (!$value instanceof EmptyRequestAttributeValue) {
         // This is a new v8 attribute type
         $value->setGenericValue($genericValue);
         $orm->persist($value);
         $orm->flush();
         $category = $this->legacyAttributeKey->getAttributeCategory();
         $indexer = $category->getSearchIndexer();
         if ($indexer) {
             $indexer->indexEntry($category, $attributeValue, $this);
         }
         return $attributeValue;
     }
 }