Skip to content

Instantly share code, notes, and snippets.

View sun's full-sized avatar
👌
Happy

Daniel Kudwien sun

👌
Happy
View GitHub Profile
@sun
sun / ModuleEnable.php
Created October 9, 2012 00:36
ModuleEnable test
<?php
/**
* @file
* Contains Drupal\system\Tests\Module\ModuleEnable.
*/
namespace Drupal\system\Tests\Module;
use Drupal\simpletest\WebTestBase;
@sun
sun / gist:3695687
Created September 11, 2012 03:14
bench: Compare Boolean value to FALSE
> php bench.php
Peak memory before test: 422.43 KB
Iterations: 1,000,000
nothing: 0.2577 seconds
function no_op(): 1.4858 seconds
!$value: 0.3877 seconds
$value === FALSE: 0.3837 seconds
FALSE === $value: 0.3868 seconds
$value == FALSE: 0.3889 seconds
@sun
sun / gist:3615986
Created September 4, 2012 02:47
Translatable config strings
$yaml = Yaml::dump('sun.settings.yml'):
id: my_settings
label: !!php/object:O:1:"t":1:{s:9:"*string";s:12:"Translate me";}
var_dump($parsed = Yaml::parse($yaml)):
array(2) {
["id"]=>
string(11) "my_settings"
["label"]=>
object(t)#34 (1) {
@sun
sun / ConfigObject.php
Created May 29, 2012 05:59
simple config object
<?php
namespace Drupal\Core\Config;
use Drupal\Core\Config\StorageInterface;
class ConfigObject {
protected $name = '';
@sun
sun / gist:2822341
Created May 29, 2012 03:20
config() new
<?php
function config($name, $config_class = NULL, $storage_class = NULL) {
static $config_instances = array(), $storage_instances = array();
// Set defaults.
if (!isset($config_class)) {
$config_class = 'Drupal\Core\Config\DrupalConfig';
}
if (!isset($storage_class)) {
# d.o collaboration
- http://drupal.org/project/issues/webmasters
- http://drupal.org/project/issues/infrastructure
- http://drupal.org/project/issues/drupalorg
- http://drupal.org/project/issues/project
- http://drupal.org/project/issues/project_issue
# Code
- http://drupal.org/project/issues/git_dev
- http://drupal.org/project/issues/project_git_instructions