Skip to content

Instantly share code, notes, and snippets.

@ronan-gloo
ronan-gloo / gist:6052449
Last active December 20, 2015 01:58
Quelques paramètres méconnus du router zf2 (à partir de la 2.2 pour certains)
<?php
'router' =>
[
// Active le support du translator pour les portions de route marquées par {translation_key}
// Il faut lui injecter un translator
'router_class' => 'Zend\Mvc\Router\Http\TranslatorAwareTreeRouteStack',
// Valeurs par défaut pour toutes les routes
'default_params' =>
@ronan-gloo
ronan-gloo / gist:5721982
Last active December 18, 2015 03:58
Custom functions Doctrine 2 / ZF2
'doctrine' =>
[
'configuration' =>
[
'orm_default' =>
[
'string_functions' =>
[
'func_name' => 'class_name'
],
@ronan-gloo
ronan-gloo / clone-new.php
Last active December 17, 2015 22:49
clone | new ArrayCollection
<?php
$clone = new ArrayCollection;
$steps = 10000;
$instances = [];
$start['new'] = microtime(true);
foreach (range(1, $steps) as $k) {
$instances[] = new ArrayCollection;
}
@ronan-gloo
ronan-gloo / gist:5653498
Created May 26, 2013 17:51
Convert non-associative array to associative array
<?php
$segments = ['one', 'two', 'three'];
$copy = $segments;
$assoc = [];
foreach ($segments as $key => $seg)
{
$segment = next($copy);
<?php
namespace Project\Raw {
define('VT', 100000);
$mt['NS no Backslash']['start'] = microtime(true);
for ($i = 0; $i < VT; $i++) {
is_array(VT);
is_string(VT);
is_object(VT);
<?php
// Error: Trait method init has not been applied...
class Node implements NodeInterface {
use Component\Attribute,
Component\Manipulation {
Component\Attribute::init as protected attributes;
Component\Manipulation::init as protected manipulation;
}
}
if ( ! class_exists($class))
{
if ( ! class_exists($class = $viewmodel) or ! class_exists($class = '\\View_'.ucfirst($viewmodel)))
{
throw new \OutOfBoundsException('ViewModel "View_'.ucfirst(str_replace(array('/', DS), '_', $viewmodel)).'" could not be found.');
}
}
// parent controller in global namespace
abstract class Controller_Application extends Controller {
protected static $_vm = 'application';
public function before()
{
$this->view = ViewModel::forge($this->_vm);
}
@ronan-gloo
ronan-gloo / gist:3550934
Created August 31, 2012 09:45
Fancybox html5 video iframe fullscreen
$('.fancybox').fancybox({
afterLoad: function(e) {
$(e.inner).find('iframe').attr({
'webkitallowfullscreen': true,
'mozallowfullscreen': true
});
}
});
@ronan-gloo
ronan-gloo / gist:3276553
Created August 6, 2012 16:54
is_string ?
public static function is_html($string)
{
return strlen(strip_tags($string)) < strlen($string);
}