Skip to content

Instantly share code, notes, and snippets.

View marcaddeo's full-sized avatar
🦀

Marc Addeo marcaddeo

🦀
View GitHub Profile
@marcaddeo
marcaddeo / printQuery.php
Last active December 13, 2018 16:45
A function to print out a full SelectInterface query, substituting placeholders and values
<?php
function printQuery(\Drupal\Core\Database\Query\SelectInterface $query, $exit = TRUE) {
$database = \Drupal::service('database');
$queryString = $query->__toString();
$queryArgs = $query->arguments();
$queryString = preg_replace('~\{([^\}]+)\}~', '$1', $queryString);
// Sort the args so replacements don't mess eachother up.
krsort($queryArgs);
@marcaddeo
marcaddeo / dont-save-filename-to-config.patch
Created July 10, 2018 15:21
Update the BackupDatabaseForm to not persist the filename to config, as we're using config_readonly
diff --git a/src/Form/BackupDatabaseForm.php b/src/Form/BackupDatabaseForm.php
index e9ba957..66851b1 100755
--- a/src/Form/BackupDatabaseForm.php
+++ b/src/Form/BackupDatabaseForm.php
@@ -70,11 +70,6 @@ class BackupDatabaseForm extends FormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->getValues();
- // Save filename.
- \Drupal::configFactory()->getEditable('backup_db.settings')
debug: Trying to retrieve from file cache with key id
debug: Trying to retrieve from file cache with key id
info: Bootstraping...
silly: It's not particularly silly, is it?
debug: Emitting event pre-bootstrap
debug: Event pre-bootstrap has 0 listeners
debug: Config set: {"env":{"MANPATH":"/home/travis/.nvm/versions/node/v8.9.1/share/man:/home/travis/.kiex/elixirs/elixir-1.4.5/man:/home/travis/.rvm/rubies/ruby-2.4.1/share/man:/usr/local/man:/usr/local/cmake-3.9.2/man:/usr/local/clang-5.0.0/share/man:/usr/local/share/man:/usr/share/man:/home/travis/.rvm/man","SSH_AGENT_PID":"4029","XDG_SESSION_ID":"2","MYSQL_UNIX_PORT":"/var/run/mysqld/mysqld.sock","TRAVIS_FILTERED":"redirect_io","rvm_bin_path":"/home/travis/.rvm/bin","GEM_HOME":"/home/travis/.rvm/gems/ruby-2.4.1","HAS_JOSH_K_SEAL_OF_APPROVAL":"true","NVM_CD_FLAGS":"","PYENV_ROOT":"/opt/pyenv","TRAVIS_STACK_JOB_BOARD_REGISTER":"/.job-board-register.yml","SHELL":"/bin/bash","TERM":"screen-256c
@marcaddeo
marcaddeo / password_policy-validation_message.patch
Last active November 3, 2018 17:39
Add error validation messages
diff --git a/password_policy.module b/password_policy.module
index 6b8d956..edd5c5b 100644
--- a/password_policy.module
+++ b/password_policy.module
@@ -10,6 +10,7 @@ use Drupal\password_policy\Entity\PasswordPolicy;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\user\UserInterface;
+use Drupal\Component\Render\FormattableMarkup;
diff --git a/src/ActionLink/ActionLinkTypeBase.php b/src/ActionLink/ActionLinkTypeBase.php
index a14e37e..bc2a154 100644
--- a/src/ActionLink/ActionLinkTypeBase.php
+++ b/src/ActionLink/ActionLinkTypeBase.php
@@ -11,6 +11,7 @@ use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\Session\SessionManagerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;