This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\se_core\Plugin\Field\FieldWidget; | |
use Drupal; | |
use Drupal\Component\Utility\Color; | |
use Drupal\Component\Utility\NestedArray; | |
use Drupal\Core\Field\FieldItemListInterface; | |
use Drupal\Core\Field\WidgetBase; | |
use Drupal\Core\Form\FormStateInterface; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\se_core\Plugin\Field\FieldWidget; | |
use Drupal; | |
use Drupal\Component\Utility\Color; | |
use Drupal\Core\Field\FieldItemListInterface; | |
use Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget; | |
use Drupal\Core\Field\WidgetBase; | |
use Drupal\Core\Form\FormStateInterface; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\se_core\Helpers; | |
use DateTimeInterface; | |
use DateTimeZone; | |
use Drupal\Core\Entity\Query\QueryInterface; | |
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface; | |
use Drupal\field\Entity\FieldStorageConfig; | |
use RuntimeException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$version = class_exists('\Drupal') ? Drupal::VERSION : NULL; | |
$version = $version ?? (defined('VERSION') ? constant('VERSION') : NULL); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Throw an exception for a bash file, message and exit code. | |
* | |
* This class creates an exception where getFile returns a path with the correct | |
* basename, and in some cases the correct line number where the exit code | |
* occurred. | |
*/ | |
class ThrowShellError { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AKlump\PHPUnit; | |
/** | |
* Given a mock object make it iterable using $data. | |
* | |
* @url https://stackoverflow.com/a/32422586 | |
* | |
* @code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// For a given html structure: | |
// | |
// <span class="image"><img src="..."></span> | |
// | |
// Use this in your SCSS file: | |
// | |
// .image { | |
// @include lifted-corners() | |
// } |