/** * @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; } }
public function addAttributeKey($type, $args, $pkg = false) { if (!is_object($type)) { $type = \Concrete\Core\Attribute\Type::getByHandle($type); } $controller = $type->getController(); $settings = $controller->saveKey($args); if (!is_object($settings)) { $settings = $controller->getAttributeKeySettings(); } // $key is actually an array. $handle = $args['akHandle']; $name = $args['akName']; $key = new LegacyKey(); $key->setAttributeKeyHandle($handle); $key->setAttributeKeyName($name); $key->setAttributeType($type); $this->entityManager->persist($key); $this->entityManager->flush(); $settings->setAttributeKey($key); $this->entityManager->persist($settings); $this->entityManager->flush(); $key->setAttributeKeySettings($settings); $key->setAttributeCategoryEntity($this->getCategoryEntity()); if (is_object($pkg)) { $key->setPackage($pkg); } // Modify the category's search indexer. $indexer = $this->getSearchIndexer(); if (is_object($indexer)) { $indexer->updateRepositoryColumns($this, $key); } $this->entityManager->persist($key); $this->entityManager->flush(); $this->clearAttributeSet($key); if (isset($args['asID']) && $args['asID'] > 0) { $key->setAttributeSet(Set::getByID($args['asID'])); } $this->entityManager->flush(); return $key; }