Skip to content

Instantly share code, notes, and snippets.

View sheanhoxie's full-sized avatar

Shean Hoxie sheanhoxie

View GitHub Profile
@sheanhoxie
sheanhoxie / Find a rogue built-in php server that's listening on a port, and kill it
Created February 3, 2020 19:59
Sometimes running xdebug with PHPStorm will not kill a php built-in web server after it's done, resulting in an error saying that something is already listening on that port.
Find what's listening on port 8080
==================================
sudo lsof -P -iTCP -sTCP:LISTEN | grep -i 8080
ex. output
----------
php 8046 username 5u IPv4 0xd9c3cdd5c98d4b65 0t0 TCP localhost:8080 (LISTEN)
Kill It
=======
@sheanhoxie
sheanhoxie / set WebDriverTestBase inspection break
Created February 1, 2020 19:03
set a break in your code so that you can poke around the chromedriver browser for debug
$this->assertSession()->waitForElementVisible('css', '.non-exist-element', 9999999999999);
run:
chromedriver --port=4444
in php.local.xml:
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox", "--disable-dev-shm-usage"]}}, "http://localhost:4444"]'/>
DRUSH SSET
drush sset STATE_NAME VAL
ex.
drush sset ftp_module_name.settings.ftp_last SV20190901.TXT
DRUSH EV
drush ev "\Drupal::state()->set('STATE_NAME', 'VAL')";
ex.
@sheanhoxie
sheanhoxie / Drupal: Add value to a multi field
Last active March 11, 2021 09:44
Methods for creating, and updating multi-value fields in Drupal 8
Add a single value to an existing multi-value field
---------------------------------------------
$value = 'text';
$profile = Profile::load(uid);
$profile->get('field_name')->appendItem($value);
Add values to a multi-value during entity creation
--------------------------------------------------
drush sqlq "DELETE FROM semaphore WHERE name = 'cron';"
@sheanhoxie
sheanhoxie / Block suggestions for custom block bundles
Created May 9, 2019 23:30
Drupal 8 - Block suggestions for custom block bundles.
https://www.drupal.org/forum/support/theme-development/2016-05-12/theming-custom-block-types#comment-11184655
/**
* Implements hook_theme_suggestions_HOOK_alter()
* @param array $suggestions
* @param array $variables
*/
function THEMENAME_theme_suggestions_block_alter(array &$suggestions, array $variables) {
// Block suggestions for custom block bundles.
if (isset($variables['elements']['content']['#block_content'])) {
echo -n 'input_here' | openssl base64
Problem:
--------
Trying to get a test to use a custom handler, defaultConfiguration()
in QuizFormHandler references a configuration setting called 'training_program'.
In order for this to work properly during install, Drupal needs to know the schema
of any handlers that have configuration settings
Webform missing schema error
----------------------------
Drupal\Core\Config\Schema\SchemaIncompleteException :
# Drupal 8 - Used to check all boxes, to grant all permissions
# to authenticated user on /admin/people/permissions
jQuery('input.rid-authenticated').each(function(e){
jQuery(this).prop("checked", true)
});