Skip to content

Instantly share code, notes, and snippets.

@szeidler
szeidler / DrushCommandsTest.php
Created April 8, 2024 10:59
Test drush commands as a functional test
<?php
namespace Drupal\Tests\staffing_figures_api\Functional;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\BrowserTestBase;
use Drush\TestTraits\DrushTestTrait;
/**
* Tests the Drush commands provided by the staffing_figures_api module.
@szeidler
szeidler / 0.DRCMD.README.md
Created May 4, 2022 14:27 — forked from esolitos/0.DRCMD.README.md
Drush command "executor" on alias pattern. Built for Wodby aliases naming standard, but can work on other setups.

DrCmd - DrushComander

drush command runner for Wodby aliases

0. Install

Save the file in /usr/local/bin/ (or anywhere else as long as it is in your $PATH) and verify that it is executable.

a. Right click on "Raw" button (for drcmd) and copy the URL.

@szeidler
szeidler / upgrade_solr_schema_wodby.sh
Created November 8, 2021 10:51
Upgrade solr schema on wodby
#!/bin/bash
# Remove existing core with data
make delete core=default -f /usr/local/bin/actions.mk
# Add new core based on search_api_solr module version
make create core=default config_set=search_api_solr_4.2.1 -f /usr/local/bin/actions.mk
@szeidler
szeidler / check-php-compatibility.sh
Created October 26, 2021 09:20
Check code for PHP compatibility issues
#!/bin/bash
# Installation:
# - composer global require "squizlabs/php_codesniffer"
# - composer global require phpcompatibility/php-compatibility
phpcs -p . --standard=PHPCompatibility --runtime-set testVersion 7.4
@szeidler
szeidler / 3224340.patch
Last active August 16, 2021 11:32
drupal/scheduler Hardcoded local task dependency on view scheduler_scheduled_content https://www.drupal.org/project/scheduler/issues/3224340
diff --git a/scheduler.links.task.yml b/scheduler.links.task.yml
index fed60f7..88810ac 100644
--- a/scheduler.links.task.yml
+++ b/scheduler.links.task.yml
@@ -10,22 +10,6 @@ scheduler.cron_tab:
weight: 10
base_route: scheduler.admin_form
-content_moderation.content:
- # Use content_moderation.content which is the same key as is used in the core
diff --git a/publication_date.install b/publication_date.install
index df9495a..b9090b0 100755
--- a/publication_date.install
+++ b/publication_date.install
@@ -34,3 +34,19 @@ function _publication_date_update_existing() {
->from($nids)
->execute();
}
+
+/**
@szeidler
szeidler / scheduler-entity-agnostic-scheduler_content_moderation_integration.patch
Created July 28, 2021 16:43
Support scheduler entity agnostic changes in scheduler_content_moderation_integration
diff --git a/src/EventSubscriber/SchedulerEventSubscriber.php b/src/EventSubscriber/SchedulerEventSubscriber.php
index ff46ac3..1025ff3 100644
--- a/src/EventSubscriber/SchedulerEventSubscriber.php
+++ b/src/EventSubscriber/SchedulerEventSubscriber.php
@@ -30,7 +30,9 @@ class SchedulerEventSubscriber implements EventSubscriberInterface {
public function publishImmediately(SchedulerEvent $event) {
/** @var \Drupal\node\Entity\Node $node */
$node = $event->getNode();
- $node->set('moderation_state', $node->publish_state->getValue());
+ if ($node->hasField('moderation_state')) {
diff --git a/scheduler.module b/scheduler.module
index 4e959da..98c1ee1 100644
--- a/scheduler.module
+++ b/scheduler.module
@@ -287,9 +287,12 @@ function _scheduler_entity_type_form_alter(&$form, FormStateInterface $form_stat
/** @var \Drupal\Core\Entity\EntityTypeInterface $type */
$type = $form_state->getFormObject()->getEntity();
- /** @var Drupal\Core\Entity\ContentEntityTypeInterface $ContentEntityType */
+ /** @var Drupal\Core\Entity\ContentEntityTypeInterface $contentEntityType */
diff --git a/.travis.yml b/.travis.yml
index 623d2f8..575bec6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -51,7 +51,7 @@ before_script:
# 24 October 2020 this bumped the version to Composer 2. Drupal Core 8.8 has
# plugins that only run with composer-plugin-api ^1.0 so revert to Composer 1.
- if [ "$DRUPAL_CORE" == "8.8.x" ]; then
- travis_retry composer self-update --1;
+ travis_retry composer self-update --1;
@szeidler
szeidler / EmbedSubscriber.php
Created July 5, 2021 09:25
Whitelist specific pages for iframe embedding by removing the X-Frame-Options header in Drupal
<?php
// REMOVE ME: Place in /web/modules/custom/mymodule/src/EventSubscriber/EmbedSubscriber.php
namespace Drupal\mymodule_embed\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;