We are using solr for search index.
Solr need to be configured for drupal. Follow the INSTALL.txt found in the search_api_solr
module.
As a pre-requisite for running your own Solr server, you'll need Java 6 or higher.
<?php | |
$path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias'); | |
if(preg_match('/node\/(\d+)/', $path, $matches)) { | |
$node = \Drupal\node\Entity\Node::load($matches[1]); | |
} |
<?php | |
// Some entity alias (node, taxonomy_term, user, etc). | |
$alias = '/about'; | |
// Get URL obj. | |
$url = Url::fromUri('internal:' . $alias); | |
// Check exist alias. | |
if ($url->isRouted()) { | |
$params = $url->getRouteParameters(); | |
$entity_type = key($params); | |
// GEt entity. |
<?php | |
/** | |
* Implements hook_form_alter(). | |
*/ | |
function MYMODULE_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { | |
$view_names = array('my_view_name'); | |
$view = $form_state->getStorage('view'); | |
if ($form_id == 'views_exposed_form' && in_array($view['view']->id(), $view_names)) { | |
// Do some shilzzle. |
<?php | |
// Import arbitrary config from a variable. | |
// Assumes $data has the data you want to import for this config. | |
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html'); | |
$config->setData($data)->save(); | |
// Or, re-import the default config for a module or profile, etc. | |
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module'); |