Skip to content

Instantly share code, notes, and snippets.

@DanielVeza
DanielVeza / simple-js
Created June 21, 2021 23:45
Dump js for testing external
var condition = FALSE;
if (!condition) {
var name = "test"
}
console.log(name)
<?php
function csvToArray($string $path, boolean $removeHeader = true) : array {
$realPath = drupal_realpath($path);
// CSV to array
$csvRows = array_map('str_getcsv', file($realPath));
if ($removeHeader) {
// Remove header row
unset($csvRows[0]);
}
@DanielVeza
DanielVeza / gist:811150abe0ce4442c8911c81c95982bf
Created October 21, 2019 20:32 — forked from jtdp/gist:5443297
See changes before pulling from remote git repository
# fetch the changes from the remote
git fetch origin
# show commit logs of changes
git log master..origin/master
# show diffs of changes
git diff master..origin/master
# apply the changes by merge..
@DanielVeza
DanielVeza / themename.theme
Created August 1, 2019 02:09
Remove the Drupal 8 generator meta tag
/**
* Implements hook_page_attachments_alter().
*
* Removes the "Generator" tag from the <head>.
* This needs to be in the theme despite it being a hook.
*/
function themename_page_attachments_alter(array &$page) {
$html_head =& $page['#attached']['html_head'];
// Get the index for the "Generator" tag.
$system_meta_generator_index = array_search('system_meta_generator', array_column($html_head, 1));
@DanielVeza
DanielVeza / FallbackAliasStorage.php
Created July 31, 2019 01:48 — forked from mohit-rocks/FallbackAliasStorage.php
Multilingual URL Alias Fallback
<?php
namespace Drupal\my_module;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Path\AliasStorageInterface;
class FallbackAliasStorage implements AliasStorageInterface {
@DanielVeza
DanielVeza / DownloadSubmissions.php
Created July 20, 2019 21:18
Custom webform action - Download submissions from multiple webforms
<?php
// Made on request from a user on drupal slack.
// Not fully tested - I've stripped this from a module I made from a client and not tested it still works after
// removing some functionality specific to that site.
// *Should work* and be a good starting point at least.
// Put this in a custom module - The example I took this from was called webfrom_extras.
// This may need minor modification - I've scrubbed data from it.
@DanielVeza
DanielVeza / MyService.php
Created March 18, 2019 00:09 — forked from JeffTomlinson/MyService.php
Drupal 8 Logger Dependency Injection - Currently outdated - Update soon. Comment if interested and I'll speed up :)
<?php
namespace Drupal\my_module\Services;
use Drupal\Core\Logger\LoggerChannelFactory;
/**
* Class MyService.
*
* @package Drupal\my_module\Services