Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris McIntosh cmcintosh

View GitHub Profile
View starbase.deltaui
PROJECT: DELTA UI
BY: Oo
COMPANY: io
V: 1.1
LIC: FREE if you leave in the credit
$: Any IN-GAME donations are welcome
---------------------------------------------------------------------------
#### HOW TO INSTALL
@cmcintosh
cmcintosh / composer.json
Created Jan 19, 2021 — forked from mpociot/composer.json
Simple ReactPHP chat server - connect to it: nc laracon.beyondco.de 8000
View composer.json
{
"require": {
"react/event-loop": "^1.1",
"react/stream": "^1.1",
"react/promise": "^2.8",
"react/socket": "^1.6",
"react/http": "^1.2",
"nubs/random-name-generator": "^2.2"
}
}
View D8 | Programmatically Create Field.md
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;

$bundles = ['user'];

$fields['user_picture'] = [
  'type' => 'image',
  'entity_type' => 'user',
  'bundle' => 'user',
@cmcintosh
cmcintosh / import.php
Created Aug 6, 2020 — forked from mikecrittenden/import.php
Importing Drupal 8 config programmatically
View import.php
<?php
// Import arbitrary config from a variable.
// Assumes $data has the data you want to import for this config.
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html');
$config->setData($data)->save();
// Or, re-import the default config for a module or profile, etc.
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module');
View gist:afc2d0ceb40e5710984abe039a184dd4
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
// Cache this for 1 minute.
return 60;
}
View gist:e311f3c0b166c5258156d3aa69418f45
/**
* Sets expires and max-age for bubbled-up max-age values that are > 0.
*
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
* The response event.
*
* @throws \Exception
* Thrown when \DateTime() cannot create a new date object from the
* arguments passed in.
*/
View gist:40af561958519db6d098f215b5a4d028
/**
* Merges max-age values (expressed in seconds), finds the lowest max-age.
*
* Ensures infinite max-age (Cache::PERMANENT) is taken into account.
*
* @param int $a
* Max age value to merge.
* @param int $b
* Max age value to merge.
*
View gist:aea3d22332e95d7d470de87e610dacbc
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return Cache::mergeContexts(parent::getCacheContexts(), [
'user.roles',
'url.path',
'group'
]);
}
View gist:a4af632e8747f4874ad02e3d022ef9ab
<?php
/**
* @ingroup views_access_plugins
*
* @ViewsAccess(
* id = "temple_of_doom",
* title = @Translation("Temple of Doom"),
* help = @Translation("No bad guys will enter, only Dr Jones may set foot inside.")
* )
View TempleOfDoomAccessHandler.php
<?php
class TempleOfDoomAccessHandler {
public function isJones(AccountInterface $account) { }
public function isBadGuy(AccountInterface $account) { }
public function access(AccountINterface $account, Route $route) {