This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Drupal\mymodule\StackMiddleware; | |
use Symfony\Component\HttpFoundation\InputBag; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
use Symfony\Component\HttpKernel\HttpKernelInterface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drush\Commands\DrushCommands; | |
/** | |
* @file | |
* Reset module hook_post_update_NAME | |
* | |
* A tool for developing and debugging post_update hooks. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat hello.php | terminus remote:wp ${SITE}.${ENV} -- eval-file - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\Tests\humanstxt\Functional; | |
use Drupal\Tests\BrowserTestBase; | |
use Drupal\Core\Url; | |
/** | |
* Tests basic functionality of configured humans.txt files. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get taxonomy terms sorted by weight. | |
* | |
* @param int $vid | |
* The vocabulary id. | |
* | |
* @return array | |
* Returns an array of term id | name. | |
* | |
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"rules": [ | |
{ | |
"description": "change home key to command + left_arrow", | |
"manipulators": [ | |
{ | |
"from": { | |
"key_code": "home" | |
}, | |
"to": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// chaining with .entity. | |
$query = \Drupal::entityQuery('node'); | |
$articles_by_name = $query->condition('type', 'article') | |
->condition('uid.entity.name', 'admin') | |
->execute(); | |
//Equal/>=/<=/etc (3rd parameter) | |
// Find particular nodes published in the last year. | |
$query = \Drupal::entityQuery('node'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function THEMENAME_theme_suggestions_block_alter(array &$suggestions, array $variables) { | |
if (isset($variables['elements']['content']['#block_content'])) { | |
$suggestions[] = 'block__' . $variables['elements']['content']['#block_content']->bundle(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MYMODULE_template_preprocess_default_variables_alter(&$variables) { | |
$current_path = \Drupal::service('path.current')->getPath(); | |
$variables['current_path'] = $current_path; | |
} |
NewerOlder