Skip to content

Instantly share code, notes, and snippets.

View larowlan's full-sized avatar
:shipit:
Framework Manager, Drupal Core

Lee Rowlands larowlan

:shipit:
Framework Manager, Drupal Core
View GitHub Profile
@larowlan
larowlan / yourtheme.theme.php
Created January 21, 2021 21:31
Preprocess a layout to work out if its in layout builder UI
<?php
/**
* Implements hook_preprocess_HOOK() for your_layout().
*/
function your_theme_preprocess_your_layout(&$vars) {
// Note this only works for 'defaults'. You could adapt it for OverridesSectionStorage.
// Ascertain if we're in layout-builder edit mode.
$parameters = \Drupal::routeMatch()->getParameters();
$vars['is_layout_builder'] = FALSE;
$cache = new CacheableMetadata();
@larowlan
larowlan / yourmodule.post_update.php
Created August 4, 2020 06:33
Create a missing block
/**
* Create a missing block (with empty fields but matching UUID).
*/
function yourmodule_post_update_create_a_missing_block() {
$block_entity_manager = \Drupal::service('entity.manager')->getStorage('block_content');
$missing_uuid = 'CE7DA6B0-C2A0-4EE9-8F6B-8854A3705FB7';
$block = $block_entity_manager->create([
'info' => 'Block title goes here',
'type' => 'block_type_machine_name_here',
<?php
class SomeClass extends BlockBase {
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
$contexts = parent::getCacheContexts();
// Tell Drupal that this block should be cached per-user.
$contexts[] = 'user';
@larowlan
larowlan / docker-compose.yml
Created November 19, 2017 23:15
d4d mount my own
version: "2"
services:
mariadb:
image: wodby/mariadb:10.1-2.3.5
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
@larowlan
larowlan / docker-compose.yml
Created October 9, 2017 21:24
docker-compose.yml
version: "2"
services:
mariadb:
image: wodby/drupal-mariadb:1.0.0
environment:
MYSQL_RANDOM_ROOT_PASSWORD: 1
MYSQL_DATABASE: local
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
diff --git a/core/modules/block_content/block_content.install b/core/modules/block_content/block_content.install
index 6af2ac4e8f..c6556e719c 100644
--- a/core/modules/block_content/block_content.install
+++ b/core/modules/block_content/block_content.install
@@ -6,6 +6,23 @@
*/
use Drupal\Core\Field\BaseFieldDefinition;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+
ERROR: TypeCoercion - core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php:61 - Argument 1 of Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateConstraintValidator::__construct expects Drupal\Core\Entity\EntityTypeManagerInterface, parent type object provided
$container->get('entity_type.manager'),
INFO: MissingReturnType - core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php:59 - Method Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateConstraintValidator::create does not have a return type
ERROR: PossiblyNullReference - core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php:81 - Cannot call method hasState on possibly null variable $workflow
if (!$workflow->hasState($entity->moderation_state->value)) {
ERROR: PossiblyNullReference - core/modules/content_moderation/src/Plugin/Validation/Constraint/Moderatio
#!/usr/bin/make -f
phpcs:
cd drupal && vendor/bin/phpcs --standard="core/phpcs.xml.dist" `git diff --staged --name-only --diff-filter=AM`
phpcs-diff:
cd drupal && vendor/bin/phpcs --standard="core/phpcs.xml.dist" `git diff --name-only --diff-filter=AM`
phpcbf:
cd drupal && vendor/bin/phpcbf --standard="core/phpcs.xml.dist" `git diff --name-only --diff-filter=AM`
diff --git a/src/Commands/Billable.php b/src/Commands/Billable.php
index 2df9683..39bb721 100644
--- a/src/Commands/Billable.php
+++ b/src/Commands/Billable.php
@@ -28,6 +28,7 @@ class Billable extends Command implements ConfigurableService {
const DAY = 'day';
const MONTH = 'month';
const FORTNIGHT = 'fortnight';
+ const SATURDAY = 6;
<?php
$config['system.logging']['error_level'] = 'verbose';
// See https://gist.github.com/larowlan/5baca05f5be4e5582777a9904ecaec41 for contents.
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/default/services.local.yml';
$config['system.performance']['js']['preprocess'] = FALSE;
$config['system.performance']['css']['preprocess'] = FALSE;
$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
$settings['extension_discovery_scan_tests'] = TRUE;