/** * Enables a search index without a confirmation form. * * @param \Drupal\search_api\IndexInterface $search_api_index * The index to be enabled. * * @return \Symfony\Component\HttpFoundation\Response * The response to send to the browser. */ public function indexBypassEnable(IndexInterface $search_api_index) { // Enable the index. $search_api_index->setStatus(TRUE)->save(); // \Drupal\search_api\Entity\Index::preSave() doesn't allow an index to be // enabled if its server is not set or disabled. if ($search_api_index->status()) { // Notify the user about the status change. drupal_set_message($this->t('The search index %name has been enabled.', array('%name' => $search_api_index->label()))); } else { // Notify the user that the status change did not succeed. drupal_set_message($this->t('The search index %name could not be enabled. Check if its server is set and enabled.', array('%name' => $search_api_index->label()))); } // Redirect to the index's "View" page. $url = $search_api_index->urlInfo('canonical'); return $this->redirect($url->getRouteName(), $url->getRouteParameters()); }
/** * {@inheritdoc} */ public function urlInfo($rel = 'canonical', array $options = array()) { return $this->entity->urlInfo($rel, $options); }