public function updateRepositoryColumns(CategoryInterface $category, AttributeKeyInterface $key, $previousHandle = null)
 {
     if ($this->isValid($category)) {
         $attributeIndexer = $key->getSearchIndexer();
         $attributeIndexer->updateSearchIndexKeyColumns($category, $key, $previousHandle);
     }
 }
 /**
  * @param StandardSearchIndexerInterface $category
  * @param Key $key
  * @param $previousHandle
  */
 public function updateSearchIndexKeyColumns(CategoryInterface $category, AttributeKeyInterface $key, $previousHandle = null)
 {
     $controller = $key->getController();
     /*
              * Added this for some backward compatibility reason – but it's obviously not
              * right because it makes it so no search index columns get created.
             if (!$previousHandle) {
                 $previousHandle = $key->getAttributeKeyHandle();
             }*/
     if ($key->getAttributeKeyHandle() == $previousHandle || $key->isAttributeKeySearchable() == false || $category->getIndexedSearchTable() == false || $controller->getSearchIndexFieldDefinition() == false) {
         return false;
     }
     $fields = array();
     $dropColumns = array();
     $definition = $controller->getSearchIndexFieldDefinition();
     $sm = $this->connection->getSchemaManager();
     $toTable = $sm->listTableDetails($category->getIndexedSearchTable());
     if ($previousHandle) {
         if (isset($definition['type'])) {
             $dropColumns[] = 'ak_' . $previousHandle;
         } else {
             foreach ($definition as $name => $column) {
                 $dropColumns[] = 'ak_' . $previousHandle . '_' . $name;
             }
         }
     }
     if (isset($definition['type'])) {
         if (!$toTable->hasColumn('ak_' . $key->getAttributeKeyHandle())) {
             $fields[] = array('name' => 'ak_' . $key->getAttributeKeyHandle(), 'type' => $definition['type'], 'options' => $definition['options']);
         }
     } else {
         foreach ($definition as $name => $column) {
             if (!$toTable->hasColumn('ak_' . $key->getAttributeKeyHandle() . '_' . $name)) {
                 $fields[] = array('name' => 'ak_' . $key->getAttributeKeyHandle() . '_' . $name, 'type' => $column['type'], 'options' => $column['options']);
             }
         }
     }
     $fromTable = $sm->listTableDetails($category->getIndexedSearchTable());
     $parser = new \Concrete\Core\Database\Schema\Parser\ArrayParser();
     $comparator = new \Doctrine\DBAL\Schema\Comparator();
     if ($previousHandle != false) {
         foreach ($dropColumns as $column) {
             $toTable->dropColumn($column);
         }
     }
     $toTable = $parser->addColumns($toTable, $fields);
     $diff = $comparator->diffTable($fromTable, $toTable);
     if ($diff !== false) {
         $sql = $this->connection->getDatabasePlatform()->getAlterTableSQL($diff);
         $arr = array();
         foreach ($sql as $q) {
             $arr[] = $q;
             $this->connection->exec($q);
         }
     }
 }
 protected function executeUpdate(AttributeKeyInterface $key, $successURL, $onComplete = null)
 {
     $entity = $this->getCategoryObject();
     $category = $entity->getAttributeKeyCategory();
     $validator = $key->getController()->getValidator();
     $response = $validator->validateUpdateKeyRequest($category, $key, $this->request);
     if (!$response->isValid()) {
         $this->error = $response->getErrorObject();
     } else {
         $category->updateFromRequest($key, $this->request);
         $this->assignToSetFromRequest($key);
         if ($onComplete instanceof \Closure) {
             $onComplete();
         }
         $this->flash('success', t('Attribute updated successfully.'));
         $this->redirect($successURL);
     }
 }
 public function __construct(AttributeKeyInterface $key)
 {
     $this->key = $key;
     parent::__construct($key->getAttributeType());
 }
 public function getEditAttributeKeyURL(AttributeKeyInterface $key)
 {
     $args = array($this->getDashboardPagePath(), $this->getDashboardPageEditAction());
     $args = array_merge($args, $this->getDashboardPageParameters(), array($key->getAttributeKeyID()));
     return call_user_func_array(array('\\URL', 'to'), $args);
 }