protected function getIndexEntryColumn(Key $key, $subKey = false) { if ($subKey) { $column = sprintf('ak_%s_%s', $key->getAttributeKeyHandle(), $subKey); } else { $column = sprintf('ak_%s', $key->getAttributeKeyHandle()); } return $column; }
public function preRemove(AttributeKey $key, LifecycleEventArgs $event) { $em = $event->getEntityManager(); $category = $key->getAttributeCategory(); // Delete the category key record $category->deleteKey($key); // take care of the settings $controller = $key->getController(); $controller->deleteKey(); // Delete from any attribute sets $r = $em->getRepository('\\Concrete\\Core\\Entity\\Attribute\\SetKey'); $setKeys = $r->findBy(array('attribute_key' => $key)); foreach ($setKeys as $setKey) { $em->remove($setKey); } }
/** * @param Key $ak * @param $option * @param int $isEndUserAdded * @return Option */ public static function add($ak, $value, $isEndUserAdded = 0) { /** * @var $type SelectSettings */ $type = $ak->getAttributeKeySettings(); $list = $type->getOptionList(); $option = new SelectValueOption(); $option->setSelectAttributeOptionValue($value); $option->setIsEndUserAdded($isEndUserAdded); $option->setOptionList($list); $em = \Database::connection()->getEntityManager(); $em->persist($option); $em->flush(); return $option; }
/** * @param UserKey $key * @param Request $request * * @return Key */ protected function saveFromRequest(Key $key, Request $request) { $key->setAttributeKeyDisplayedOnProfile((string) $request->request->get('uakProfileDisplay') == 1); $key->setAttributeKeyEditableOnProfile((string) $request->request->get('uakProfileEdit') == 1); $key->setAttributeKeyRequiredOnProfile((string) $request->request->get('uakProfileEditRequired') == 1); $key->setAttributeKeyEditableOnRegister((string) $request->request->get('uakRegisterEdit') == 1); $key->setAttributeKeyRequiredOnRegister((string) $request->request->get('uakRegisterEditRequired') == 1); $key->setAttributeKeyDisplayedOnMemberList((string) $request->request->get('uakMemberListDisplay') == 1); return $key; }
/** * @param ExpressKey $key * @return string */ public function generate(Key $key) { $name = $key->getAttributeKeyName(); $text = \Core::make('helper/text'); $handle = $text->handle($name); if (!$handle) { $handle = 'attribute_key'; } $baseHandle = substr($handle, 0, 42); if ($this->handleIsAvailable($baseHandle, $key)) { return $baseHandle; } $suffix = 2; $handle = $baseHandle . '_' . $suffix; while (!$this->handleIsAvailable($handle, $key)) { $suffix++; $handle = $baseHandle . '_' . $suffix; } return $handle; }
public function load(Key $key, Request $request) { $key->setAttributeKeyName($request->request->get('akName')); $key->setAttributeKeyHandle($request->request->get('akHandle')); $key->setIsAttributeKeyContentIndexed((bool) $request->request->get('akIsSearchableIndexed')); $key->setIsAttributeKeySearchable((bool) $request->request->get('akIsSearchable')); return $key; }
public function load(Key $key, \SimpleXMLElement $element) { $key->setAttributeKeyName((string) $element['name']); $key->setAttributeKeyHandle((string) $element['handle']); $indexed = (string) $element['indexed']; $searchable = (string) $element['searchable']; $internal = (string) $element['internal']; if ($indexed === '1') { $key->setIsAttributeKeyContentIndexed(true); } if ($indexed === '1') { $key->setIsAttributeKeyContentIndexed(true); } if ($internal === '1') { $key->setIsAttributeKeyInternal(true); } return $key; }
public function updateFromRequest(Key $key, Request $request) { $previousHandle = $key->getAttributeKeyHandle(); $loader = $this->getRequestLoader(); $loader->load($key, $request); $controller = $key->getController(); $settings = $controller->saveKey($request->request->all()); if (!is_object($settings)) { $settings = $controller->getAttributeKeySettings(); } $settings->setAttributeKey($key); $this->entityManager->persist($settings); $this->entityManager->flush(); // Modify the category's search indexer. $indexer = $this->getSearchIndexer(); if (is_object($indexer)) { $indexer->updateRepositoryColumns($this, $key, $previousHandle); } $this->entityManager->persist($key); $this->entityManager->flush(); return $key; }
public function __construct(Key $attributeKey) { $this->attributeKey = $attributeKey; $this->akID = $attributeKey->getAttributeKeyID(); }
public function deleteKey(Key $key) { $values = $this->entityManager->getRepository('\\Concrete\\Core\\Entity\\Attribute\\Value\\Value\\Value')->findBy(['attribute_key' => $key]); $controller = $key->getController(); foreach ($values as $genericValue) { $legacyValue = new LegacyValue(); $legacyValue->setGenericValue($genericValue); $legacyValue->setAttributeKey($key); $controller->setAttributeValue($legacyValue); $controller->deleteValue(); $value = $legacyValue->getValueObject(); if (is_object($value)) { $this->entityManager->remove($value); $this->entityManager->flush(); } $this->entityManager->remove($genericValue); $this->entityManager->flush(); } }