Skip to content

Instantly share code, notes, and snippets.

constructor() {
this.el = document;
this.evt = (e) => {
...
}
}
// Trigger exclusion modal if a click happens anywhere except on the modal box
this.el.addEventListener('click', this.evt);
$ find / -type f -name MYFILE.TXT
$ echo "<?php phpinfo(); ?>" | php | pbcopy
$ git archive -o archive.zip HEAD $(git diff --name-only <commit_hash> <commit_hash>)
function getNodeAliases($langcode = 'en') {
$aliases = [];
$nids = \Drupal::entityQuery('node')
->condition('status', 1) // published
->condition('langcode', $langcode)
->execute();
foreach ($nids as $nid) {
$system_path = '/node/' . $nid;
$path_alias = db_query("SELECT alias FROM {url_alias} WHERE source = '$system_path' AND langcode = '{$langcode}'")->fetchField();
$aliases[] = $path_alias;
\Drupal::service("router.builder")->rebuild();
// Ordered by execution speed
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$ext = substr(strrchr($filename, '.'), 1);
$ext = substr($filename, strrpos($filename, '.') + 1);
$ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename);
function getNodeContent( $id, $lang = '' ) {
$lang = $lang ?: \Drupal::languageManager()->getCurrentLanguage()->getId();
$node = \Drupal::entityTypeManager()
->getStorage('node')
->load($id);
$translated_node = $node->getTranslation($lang);
return [$node, $translated_node];
}
@Kloport
Kloport / Set components folder
Created September 3, 2016 07:45
Create a Bower configuration file .bowerrc in the project root with the following content:
{
"directory" : "app/vendors"
}
try {
\Drupal::entityDefinitionUpdateManager()->applyUpdates();
}
catch (EntityStorageException $e) {
print_r($e);
}