Skip to content

Instantly share code, notes, and snippets.

/**
* Enables field_formatter_settings and borealis
*/
function ilr_update_7003() {
variable_set('ilr_test', 'test-value');
}
@tedbow
tedbow / single-simpletest.txt
Last active March 23, 2016 18:28
Run a single simpletest in Drupal 8
#https://www.drupal.org/node/645286
php core/scripts/run-tests.sh --url http://example.com/ --class "Drupal\module_name\Tests\TestClass::testMethod"
@tedbow
tedbow / checkout-branch-directory.txt
Created March 23, 2016 21:03
Checkout directory from git branch
#http://stackoverflow.com/questions/2668886/git-copy-all-files-in-a-directory-from-another-branch
git checkout master -- dirname
git commit -m "Something terribly misguided" (1)
$ git reset --soft HEAD~
@tedbow
tedbow / wgit-apply.sh
Created May 20, 2016 12:19
Apply a patch with saving it
path=${1}
if [ $1 ]
then
wget -q -O - $1 | git apply -
else
echo "please enter url"
exit
fi
@tedbow
tedbow / test_constructor.php
Created May 21, 2016 19:59
test_constructor.php
/**
* Constructs a new UserLoginResource object.
*
* @param \Drupal\Core\Flood\FloodInterface $flood
* The flood controller.
* @param \Drupal\user\UserStorageInterface $user_storage
* The user storage.
* @param \Drupal\Core\Access\CsrfTokenGenerator $csrf_token
* The CSRF token generator.
* @param \Drupal\user\UserAuthInterface $user_auth
@tedbow
tedbow / drude-how-to.txt
Created May 25, 2016 19:20
How I start a new project with drude.txt
1. read https://github.com/blinkreaction/drude - do 1 time setup
2. git clone --depth 1 git@github.com:tedbow/drude-d8-start.git
3.
3. drupal site:new docroot
@tedbow
tedbow / various-git.txt
Created June 15, 2016 13:33
Various git
Let’s say that I am on the master branch. But I wanted slothparadise.txt from the devel branch.
git checkout devel -- slothparadise.txt
@tedbow
tedbow / block.php
Created June 22, 2016 18:13
suggestions
$new_region = NULL;
if (!isset($regions[$this->region]) && $this->status()) {
if (isset($this->original)) {
$original_region = $this->original->getRegion();
// If \Drupal\block\BlockInterface::BLOCK_REGION_NONE was used to
// disable the block and we have an original region then keep in the
// block in the original region.
if (isset($regions[$original_region]) && $this->region == BlockInterface::BLOCK_REGION_NONE) {
$new_region = $original_region;
}
<?php
namespace Drupal\outside_in\Ajax;
use Drupal\Core\Ajax\OpenDialogCommand;
/**
* Defines an AJAX command to open content in a dialog in a off-canvas tray.
*
* @ingroup ajax