Skip to content

Instantly share code, notes, and snippets.

View fubhy's full-sized avatar

Sebastian Lorenz fubhy

View GitHub Profile
node_page_edit:
pattern: '/music/{album}/{artist}'
defaults:
_content: 'Drupal\music\MusicController::view'
requirements:
_permission: 'yeap'
options:
parameters:
album:
converter: 'paramconverter.typed_data'
foo_route:
pattern: '/some/random/{entity_type}/{entity}/route'
options:
parameters:
entity:
type: entity:{entity_type}
+ public function convert($definition, $name, array $defaults, Request $request) {
+ // Only continue if there is a value for the given parameter.
+ if (!isset($defaults[$name])) {
+ return;
+ }
+ $entity_type = substr($definition['type'], strlen('entity:'));
+ if ($storage = $this->entityManager->getStorageController($entity_type)) {
+ return $storage->load($defaults[$name]);
+ }
+ }
@fubhy
fubhy / .gitconfig
Last active September 20, 2016 02:51
My personal .gitconfig (mostly stolen from others) :-)
[user]
# Credentials.
name = Foo Bar
email = [email protected]
drupal = $(whoami)
[credential]
# Save passwords in ~/.git-credentials.
helper = store
##
## This file is only needed for Compass/Sass integration. If you are not using
## Compass, you may safely ignore or delete this file.
##
## If you'd like to learn more about Sass and Compass, see the sass/README.txt
## file for more information.
##
# Default to development if environment is not set.
saved = environment
/**
* @Route("/foo/{bar}/{baz}")
*/
class SomePage extends ControllerBase {
/**
* @Content
*/
public function content(NodeInterface $bar, UserInterface $baz) {
return 'Blaaah';
@fubhy
fubhy / SassMeister-input.scss
Created November 20, 2013 16:38
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
@import "compass";
// =============================================================================
// sass/variables/_typography.scss
// =============================================================================
@fubhy
fubhy / SassMeister-input.scss
Created November 20, 2013 17:36
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
@import "compass";
@import "singularitygs";
// Grid definition.
$grids: 2 1;
@fubhy
fubhy / SassMeister-input.scss
Created November 20, 2013 18:00
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
$base-font-size: 14px;
// =============================================================================
// sass/abstraction/_units.scss
// =============================================================================
use Guzzle\Cache\CacheAdapterInterface;
/**
* Custom cache adapter.
*
* Leverages the default Drupal cache bin system for caching Guzzle responses.
*/
class DrupalCacheAdapter implements CacheAdapterInterface {
/**