Skip to content

Instantly share code, notes, and snippets.

View jamiehollern's full-sized avatar

Jamie Hollern jamiehollern

  • Tag1 Consulting
  • Dùn Phris/Zürich
  • 23:51 (UTC +01:00)
View GitHub Profile
@WengerK
WengerK / databaseService.php
Created September 4, 2017 09:46
Drupal 8 - Print raw SQL queries for debugging
<?php
/**
* Debugging using the database connection.
*/
/** @var \Drupal\Core\Database\Connection */
$connection = \Drupal::service('database');
$query = $connection->select('node', 'node');
$query->fields('node', ['nid'])
@WengerK
WengerK / README.md
Last active January 4, 2022 21:15
Programatically use Solr on Drupal 8

🔍 Solr (6.1.0+) search Engine & Tika (1.13+) Extractor

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.

Installation

@acrosman
acrosman / SidebarCondition.php
Last active December 1, 2021 01:50
A Drupal 8 block condition to set visibility based on a node's field value.
<?php
namespace Drupal\my_block\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
# Schema for the views plugins.
views.filter.project_size_range_select:
type: views_filter
label: 'Foobar numeric'
views.filter_value.project_size_range_select:
type: views.filter_value.numeric
label: 'Foobar Numeric'
@akirattii
akirattii / docker-mysql-slow-query-log.md
Last active July 14, 2023 22:12
memo: MySQL docker container settings for slow query log

Check running mysql container:

$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
26137efa979f        mysql               "docker-entrypoint..."   8 months ago        Up 10 minutes       0.0.0.0:3306->3306/tcp   container-mysql

Check docker container mysql version:

$ sudo docker exec container-mysql mysqld --version`
mysqld  Ver 5.7.15 for Linux on x86_64 (MySQL Community Server (GPL))
@Leksat
Leksat / Composer JS libraries example.diff
Created April 26, 2017 08:03
In this example we add masonry, imagesloaded, and dropzone libraries to Composer.
diff --git a/.gitignore b/.gitignore
index fc00ed5..ac82bec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ web/core
web/modules/contrib
web/themes/contrib
web/profiles/contrib
+web/libraries
@jmolivas
jmolivas / README.md
Last active August 5, 2019 20:01
Render a form on a page via a Controller on Drupal8.

Create file at ~/console/chain/generate-controller-form-render.yml containing:

command:
  name: 'generate:controller:form:render'
  description: 'Controller + Form generator'
commands:
  - command: 'generate:module'
    options:
        module: example
@Jeff-Russ
Jeff-Russ / Array Objects in PHP.md
Last active April 5, 2024 21:07
PHP: ArrayObject, IteratorAggregate , ArrayAccess , Serializable , Countable

Array Objects in PHP

Array are not object in PHP but PHP does give us some ways to make object that act like arrays. First, there is the ArrayObject class which is pretty close to what you have with a normal array (you can iterate it, use [] etc.) If you use it as a parent for your class you can add methods to it.

class ArrObj extends ArrayObject{
	// add methods here
@JeffTomlinson
JeffTomlinson / MyService.php
Last active December 22, 2021 07:49
Drupal 8 Logger Dependency Injection
<?php
namespace Drupal\my_module\Services;
use Drupal\Core\Logger\LoggerChannelFactory;
/**
* Class MyService.
*
* @package Drupal\my_module\Services
@crittermike
crittermike / router_rebuild.sh
Created September 16, 2016 15:15
Rebuild Drupal 8 routing table with Drush
drush ev '\Drupal::service("router.builder")->rebuild();'