Skip to content

Instantly share code, notes, and snippets.

View sdboyer's full-sized avatar

sam boyer sdboyer

View GitHub Profile
@sdboyer
sdboyer / gist:5823704
Last active December 18, 2015 18:09 — forked from EclipseGc/gist:5823702
<?php
protected function renderBlocks(Request $request, BoundDisplayInterface $display) {
$blockFragments = array();
foreach ($display->getAllOuterBlockConfig() as $id => $config) {
$block = $display->getBlock($id);
if ($block instanceof SystemMainBlock) {
$block->setControllerClosure($request->attributes->get('_content_closure'));
id: frontend
label: Frontend master display
layout: static_layout:layout__core
layoutSettings: { }
blockInfo:
# these have bartik in their namespace, but that's irrelevant to our use here -
# we're just reusing them while we get everything together.
block.block.bartik.help:
region: main
region-type: main
id: frontend
label: Frontend master display
layout: static_layout:layout__core
layoutSettings: { }
staticContexts:
urlgoober:
type: string
value: path/to/node
derivedContexts:
node_author:
@sdboyer
sdboyer / BlockBase.php
Created June 21, 2013 02:39
additional title methods
<?php
/**
* @file
* Contains \Drupal\block\BlockBase.
*/
namespace Drupal\block;
use Drupal\Core\Plugin\ContextAwarePluginBase;
/Applications/MAMP/bin/php/php5.4.10/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_host=127.0.0.1 -dxdebug.remote_port=9000 -dxdebug.remote_mode=req /private/var/folders/Fc/FcQCzbUPG6OSfLW9A10OqE+++TI/-Tmp-/ide-phpunit.php -d auto_prepend_file=/Users/sdboyer/ws/dd/8chase/core/tests/bootstrap.php --configuration /Users/sdboyer/ws/dd/8chase/core/phpunit.xml.dist
Testing started at 10:09 AM ...
#!/usr/bin/php
Process finished with exit code 255
@sdboyer
sdboyer / AssetCollectorTest.php
Last active December 19, 2015 03:38
kinda ugly
<?php
try {
$this->collector->setDefaults('css', array('foo' => 'bar'));
$this->fail('No exception thrown exception when an attempt was made to change protected values while the collector was locked.');
}
catch (\Exception $e) {
$this->assertTrue(TRUE, 'Collector threw appropriate exception on lock violation.');
}
try {
<?php
/**
* @file
* Contains Drupal\Core\Asset\AssetCollector.
*/
namespace Drupal\Core\Asset;
/**
* A class that helps to create and collect assets.
<?php
/**
* @file
* Contains Drupal\Core\Asset\AssetLibraryCollector.
*/
namespace Drupal\Core\Asset;
use Drupal\Component\Utility\Crypt;
use \Drupal\Core\Asset\AssetLibraryManager;
@sdboyer
sdboyer / collector-pseudo.php
Last active December 19, 2015 03:48
pseudocode demonstrating collector behavior
<?php
class DisplayController {
protected function renderBlocks() {
$collector = new \Drupal\Core\Asset\AssetCollector();
$bag = new \Drupal\Core\Asset\AssetBag();
$collector->setBag($bag);
// So now there's a bag in the collector, and ONLY my code right here has
// access to it.
$collector->setDefaults('css', array('group' => CSS_AGGREGATE_DEFAULT));
<?php
/**
* @file
* Contains Drupal\Core\Asset\AssetCollector.
*/
namespace Drupal\Core\Asset;
/**
* A class that helps to create and collect assets.