Skip to content

Instantly share code, notes, and snippets.

View sdboyer's full-sized avatar

sam boyer sdboyer

View GitHub Profile
@sdboyer
sdboyer / gist:825176
Created February 13, 2011 21:48
merge horribleness
Original LCAS:
set(['drumm@delocalizedham.com-20110114031905-tf0ean18fij48avq',
'hudson@util.drupal.org-20101231175052-vh23b2wb4m4fuyrf',
'hudson@util.drupal.org-20110115180021-3pa9rxlzj0b4m7ux',
'hudson@util.drupal.org-20110116201349-pt6bqho1lfldzmev',
'hudson@util.drupal.org-20110124022445-53hs3ux2ek0fjw23',
'hudson@util.drupal.org-20110126103810-nz8z9m6uk958031d',
'killes@util.drupal.org-20101222010347-tqtq6pn8q9g3622d'])
Using LCAS:
set(['hudson@util.drupal.org-20110115180021-3pa9rxlzj0b4m7ux'])
@sdboyer
sdboyer / plugin-type-controllers.php
Created March 31, 2011 22:57
gibbering funlets working on plugin type controller interfaces
<?php
interface PluginControllerInterface {
/**
* Retrieve plugin metadata for the named plugin of this type.
*/
public function getPluginMetadata($name);
/**
* Retrieve plugin metadata for all plugins of this type.
*/
@sdboyer
sdboyer / .gitconfig
Created April 13, 2011 16:08 — forked from rfay/.gitconfig
# Put this in your .gitconfig
[url "ssh://git@git.drupal.org/sandbox/"]
insteadOf = "dos:"
[url "ssh://git@git.drupal.org/project/"]
insteadOf = "do:"
@sdboyer
sdboyer / gist:2901057
Created June 9, 2012 13:57
quicker search of namespace array in universal class loader
<?php
foreach ($this->namespaces as $ns => $dirs) {
if (0 !== strpos($namespace, $ns)) {
continue;
}
foreach ($dirs as $dir) {
$file = $dir.DIRECTORY_SEPARATOR.$normalizedClass;
if (is_file($file)) {
return $file;
[root@git6staging drupalfr.git]# ls -la
total 472
drwxrwsr-x 6 drupal-git drupal-git 4096 Feb 25 2011 .
drwxrwsr-x 12171 drupal-git drupal-git 446464 May 12 16:21 ..
drwxrwsr-x 2 drupal-git drupal-git 4096 Feb 25 2011 branches
-rw-rw-r-- 1 drupal-git drupal-git 668 Feb 25 2011 config
-rw-rw-r-- 1 drupal-git drupal-git 104 Feb 25 2011 description
-rw-rw-r-- 1 drupal-git drupal-git 23 Feb 25 2011 HEAD
lrwxrwxrwx 1 drupal-git drupal-git 32 May 10 09:07 hooks -> /var/git/templates/hooks/project
drwxrwsr-x 2 drupal-git drupal-git 4096 Feb 25 2011 info
@sdboyer
sdboyer / ConfigDrivenFactory.php
Last active December 15, 2015 14:29
quick POC of a config-sensitive plugin factory, and the config and plugin interfaces it entails. even if we don't do this, i think it's worth noting that i think we'd be much better served in general if we tried to do less constructor injection with plugins - setter injection is typically fine. the only drawback to it is that it could be set aga…
<?php
/**
* @file
* Contains Drupal\Core\Plugin\Factory\ConfigDrivenFactory.
*/
namespace Drupal\Core\Plugin\Factory;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\Component\Plugin\Factory\DefaultFactory;
@sdboyer
sdboyer / config.inc.php
Created April 1, 2013 13:24
new prefix-agnostic config entity loader
<?php
/**
* Loads the correct type of ConfigEntity from a full configuration object name.
*
* ConfigEntity expects that the id passed to entity_load() will not include the
* config prefix used by the entity type being loaded. This is unhelpful for
* calling code that has the fully prefixed configuration object name and can
* not reliably know the specific type of ConfigEntity to load.
*
* This function figures out which type of entity the configuration object
@sdboyer
sdboyer / block.routing.yml
Created April 3, 2013 02:29
block routes
block_address_standalone:
pattern: '/block-address/standalone/{block_config}/{route}'
defaults:
_controller: 'block_controller:respond'
requirements:
_access_addressed_block: 'TRUE'
block_address_embedded:
pattern: '/block-address/embedded/{display}'
defaults:
@sdboyer
sdboyer / Block.php
Last active December 15, 2015 19:29
still not quite done, but a better example
<?php
/**
* @file
* Contains \Drupal\block\Plugin\Core\Entity\Block.
*/
namespace Drupal\block\Plugin\Core\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
@sdboyer
sdboyer / BlockBase.php
Last active December 16, 2015 08:19
block title getting
<?php
class BlockBase {
/**
* {@inheritdoc}
*/
final public function getTitle() {
// Override titles should supersede native title logic.
if (isset($this->configuration['label'])) {
// @todo tokenization?
}