I hereby claim:
- I am aklump on github.
- I am aklump (https://keybase.io/aklump) on keybase.
- I have a public key ASB_LuPX2hRCGOYe-MYF_LW--oONccyBnVe-8WfoqQzSdgo
To claim this, I am signing this object:
// Without the use of D.I. | |
$form = \Drupal::service('entity.manager') | |
->getFormObject('node', 'default') | |
->setEntity($node); | |
$build[] = \Drupal::formBuilder()->getForm($form); | |
// Within a class using D.I. | |
class someClass { | |
public function __construct(EntityManagerInterface $entityManager) { | |
$this->entityManager = $entityManager; |
/** | |
* Implements hook_preprocess_HOOK(). | |
*/ | |
function THEMENAME_preprocess_field_multiple_value_form(&$vars) { | |
if (isset($vars['table']['#tabledrag'])) { | |
unset($vars['table']['#tabledrag']); | |
array_pop($vars['table']['#header']); | |
foreach ($vars['table']['#rows'] as &$row) { | |
foreach (array_keys($row['data']) as $key) { | |
if (array_intersect($row['data'][$key]['class'], [ |
<?php | |
function my_module_node_view_alter(&$build) | |
{ | |
if (!empty($build['field_image']) && user_is_logged_in()) { | |
$build['field_image']['#post_render'][] = 'my_module_cache_buster'; | |
} | |
} | |
function my_module_cache_buster($html, $build) | |
{ |
// | |
// | |
// Mixin for variable font sizing between two font sizes with min and max constraints. | |
// | |
// Ever want to declare a title to grow from 28px to 60px based on browser width, but always be at least 28px and never | |
// more than 60px? This SASS mixin does the heavy lifting in terms of math and media queries to figure the necessary CSS | |
// to do just that. | |
// | |
// @code | |
// @include loft-sass-font-size-range(28px to 46px at 960px); |
I hereby claim:
To claim this, I am signing this object:
// | |
// For a given html structure: | |
// | |
// <span class="image"><img src="..."></span> | |
// | |
// Use this in your SCSS file: | |
// | |
// .image { | |
// @include lifted-corners() | |
// } |
<?php | |
namespace AKlump\PHPUnit; | |
/** | |
* Given a mock object make it iterable using $data. | |
* | |
* @url https://stackoverflow.com/a/32422586 | |
* | |
* @code |
<?php | |
/** | |
* Add backslash to double quotes unless already present. | |
*/ | |
class EscapeDoubleQuotes { | |
public function __invoke(string $query): string { | |
// This is four-backslashes because of preg--confusing--that's why this | |
// class exists to remove the confusion. |
class UpperCamel { | |
public function __invoke(string $value): string { | |
$value = preg_replace('/[\s\-_]/s', ' ', $value); | |
$value = trim(preg_replace('/[A-Z]/', ' \0', $value)); | |
$value = preg_replace('/(\s)\s+/s', '\1', $value); | |
$value = ucwords($value); | |
$value = preg_replace('/\s+/s', '', $value); | |
return $value; |
class HumanList { | |
use \Drupal\Core\StringTranslation\StringTranslationTrait; | |
public function __invoke(array $items): string { | |
$last = array_pop($items); | |
return $this->t(':items and :item', [ | |
':items' => implode(', ', $items), | |
':item' => $last, |