Skip to content

Instantly share code, notes, and snippets.

View labboy0276's full-sized avatar

John Ouellet labboy0276

View GitHub Profile
@labboy0276
labboy0276 / default.vcl
Created April 8, 2017 19:31
Wordpress LEMP Varnish VCL
#
# This is an example VCL file for Varnish.
#
# It does not do anything by default, delegating control to the
# builtin VCL. The builtin VCL is called when there is no explicit
# return statement.
#
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples.
@labboy0276
labboy0276 / 2723615.patch
Created June 20, 2017 16:11
Taxonomy Entity Patch Drupal 8
diff --git a/core/modules/taxonomy/src/Controller/TaxonomyController.php b/core/modules/taxonomy/src/Controller/TaxonomyController.php
index 843cdd7..d55dc50 100644
--- a/core/modules/taxonomy/src/Controller/TaxonomyController.php
+++ b/core/modules/taxonomy/src/Controller/TaxonomyController.php
@@ -20,6 +20,9 @@ class TaxonomyController extends ControllerBase {
*
* @return array
* The taxonomy term add form.
+ *
+ * @deprecated in 8.2.x, will be removed in 9.x. Use
@labboy0276
labboy0276 / pantheon.md
Last active August 16, 2018 19:29
Pantheon to Pantheon D8 Migration

Pantheon to Pantheon Migration Setup

  1. SFTP a file called secrets.json to your D8's files/private folder.
    • Just put this in the file to make a legit json file: {}
  2. In your D8 site's settings.php put this at the bottom:
# When on Pantheon, connect to a D7 database.
$migrate_settings = __DIR__ . "/settings.migrate-on-pantheon.php";
if (file_exists($migrate_settings) && isset($_ENV['PANTHEON_ENVIRONMENT'])) {
@labboy0276
labboy0276 / donation tracking
Created November 21, 2018 14:09
donation tracking
<script type="text/javascript">
/* <![CDATA[ */
goog_snippet_vars = function() {
var w = window;
w.google_conversion_id = 1071200313;
w.google_conversion_label = "QJMECMynhmEQufDk_gM";
w.google_remarketing_only = false;
}
// DO NOT CHANGE THE CODE BELOW.
goog_report_conversion = function(url) {
diff --git a/redirect_after_login.module b/redirect_after_login.module
index 18b2f25..34a14f9 100644
--- a/redirect_after_login.module
+++ b/redirect_after_login.module
@@ -12,20 +12,24 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
*/
function redirect_after_login_user_login($account) {
$current_route = \Drupal::routeMatch()->getRouteName();
- if (!in_array($current_route, ['user.reset', 'user.reset.login'])) {
- // We want to redirect user on login
@labboy0276
labboy0276 / migrate-way-1.php
Last active March 29, 2019 01:41
Various Drupal 8 Body Migration Techniques Ways
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\MigrateSourceInterface;
use Drupal\migrate\Row;
/**
* Implements hook_migrate_prepare_row().
*/
function YOUR_MODULE_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
switch ($migration->id()) {
case 'config_name':
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 053429f4b8..44d3c5c898 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -561,8 +561,22 @@ function user_login_finalize(UserInterface $account) {
// This is called before hook_user_login() in case one of those functions
// fails or incorrectly does a redirect which would leave the old session
// in place.
- \Drupal::service('session')->migrate();
- \Drupal::service('session')->set('uid', $account->id());
@labboy0276
labboy0276 / temp.patch
Last active March 26, 2019 18:35
temp.patch
diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index f451e508fa..a32c66353b 100644
--- a/core/lib/Drupal/Core/Database/Connection.php
+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -725,7 +725,7 @@ protected function expandArguments(&$query, &$args) {
throw new \InvalidArgumentException('Placeholders with a trailing [] can only be expanded with an array of values.');
}
elseif (!$is_bracket_placeholder) {
- if ($is_array_data) {
+ if ($is_array_data && !empty($data)) {
@labboy0276
labboy0276 / header.html.twig
Created February 4, 2020 14:00
Bootstrap 4 - Drupal 8 vanilla JS menu
<header id="header" class="header" role="banner" aria-label="{{ 'Site header'|t}}">
<nav class="navbar navbar-expand-lg fixed-top" id="main-navbar">
<div class="navbar-brand d-lg-none d-xl-none">YOUR SITE NAME</div>
<button id="navbar-toggler-id" class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#CollapsingNavbar" aria-controls="CollapsingNavbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="CollapsingNavbar">
{{ page.primary_menu }}
</div>
</nav>
</header>
@labboy0276
labboy0276 / composer-private-github-platformsh.md
Created May 5, 2020 19:39
Using a GitHub Personal Access Token for Private Composer Packages on Platform.sh
  1. Visit https://github.com/settings/tokens.

  2. Click Generate new token

  3. Use the repo scope and give it a name.

  4. Run this command:

platform variable:create --project PROJECT-ID --level project --name env:COMPOSER_AUTH \