Skip to content

Instantly share code, notes, and snippets.

View LionsAd's full-sized avatar

Fabian Franz LionsAd

  • LionsAd
  • Schweiz
View GitHub Profile
@LionsAd
LionsAd / smart-placeholder-cache-wip.diff
Created February 18, 2015 15:02
SmartPlaceholderCache
diff --git a/core/lib/Drupal/Core/Render/BubbleableMetadata.php b/core/lib/Drupal/Core/Render/BubbleableMetadata.php
index c56b421..748bc0b 100644
--- a/core/lib/Drupal/Core/Render/BubbleableMetadata.php
+++ b/core/lib/Drupal/Core/Render/BubbleableMetadata.php
@@ -39,6 +39,13 @@ class BubbleableMetadata {
protected $postRenderCache;
/**
+ * #placeholder metadata.
+ *
@LionsAd
LionsAd / gist:3a03f5c7716652ff767d
Created April 28, 2015 20:11
toRenderArray support
diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index bb29cd1..5461283 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -420,7 +420,11 @@ public function renderVar($arg) {
}
if (is_object($arg)) {
- if (method_exists($arg, '__toString')) {
+ // @todo Replace with a proper interface.
@LionsAd
LionsAd / gist:c3096a5563152d7b37a4
Created May 26, 2015 15:18
Cache contexts for $access
diff --git a/core/modules/block/src/BlockRepository.php b/core/modules/block/src/BlockRepository.php
index 485a66f..e2aa34e 100644
--- a/core/modules/block/src/BlockRepository.php
+++ b/core/modules/block/src/BlockRepository.php
@@ -77,9 +77,8 @@ public function getVisibleBlocksPerRegion(array $contexts) {
foreach ($this->blockStorage->loadByProperties(array('theme' => $this->getTheme())) as $block_id => $block) {
/** @var \Drupal\block\BlockInterface $block */
// Set the contexts on the block before checking access.
- if ($block->setContexts($contexts)->access('view')) {
- $full[$block->getRegion()][$block_id] = $block;
@LionsAd
LionsAd / hack-the-renderer.diff
Last active September 1, 2015 10:55
Cleanup renderer, prepare for passing just one cacheable metadata to doRender()
diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php
index f2be9ce..82f6228 100644
--- a/core/lib/Drupal/Core/Render/Renderer.php
+++ b/core/lib/Drupal/Core/Render/Renderer.php
@@ -131,10 +131,23 @@ public function renderRoot(&$elements) {
// Render in its own render context.
$this->isRenderingRoot = TRUE;
- $output = $this->executeInRenderContext(new RenderContext(), function () use (&$elements) {
- return $this->render($elements, TRUE);
@LionsAd
LionsAd / container-decorator-test.php
Last active September 2, 2015 17:14
Test script to test container decoration
<?php
require "autoload.php";
use Drupal\Component\DependencyInjection\Dumper\PhpArrayDumper;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/*
@LionsAd
LionsAd / half-pipe.php
Created September 13, 2015 15:13
Half Pipe WIP
<?php
// ...
if (!empty($half_pipe_placeholders)) {
$extra_attachments = $this->doHalfPipe($page_parts[0], $half_pipe_placeholders);
// Print the extra attachments.
if (!empty($extra_attachments['library']) || !empty($extra_attachments['drupalSettings'])) {
$all_attachments = BubbleableMetadata::mergeAttachments($attachments, $extra_attachments);
@LionsAd
LionsAd / big_pipe_aps.diff
Created October 1, 2015 19:12
Ajax Page State Reducing
diff --git a/core/modules/big_pipe/big_pipe.module b/core/modules/big_pipe/big_pipe.module
index 724cd1c..f1af3a4 100644
--- a/core/modules/big_pipe/big_pipe.module
+++ b/core/modules/big_pipe/big_pipe.module
@@ -18,8 +18,16 @@
function big_pipe_js_settings_alter(&$settings) {
// Store the settings for later usage.
if (isset($settings['bigPipeResponseMarker'])) {
- \Drupal::service('big_pipe')->setAjaxPageState(isset($settings['ajaxPageState']) ? $settings['ajaxPageState'] : NULL);
+ $ajax_page_state = isset($settings['ajaxPageState']) ? $settings['ajaxPageState'] : NULL;
@LionsAd
LionsAd / test_php7_crash.php
Created October 29, 2015 01:21
Test PHP7 crash with Drupal 8
<?php
function foo() {}
function bar() {}
function crash_merge($attached) {
$merge = [ 'html_head' => ['2']];
$attached = array_merge_recursive(
<?php
/**
* @file
*
* Contains Drupal\newsletter_view\Controller\NewsletterViewNodeController
*/
namespace Drupal\newsletter_view\Controller;
<?php
function yac_store() {
static $yac;
if (!isset($yac)) {
$yac = new Yac('');
}
return $yac;