Skip to content

Instantly share code, notes, and snippets.

View Saeven's full-sized avatar

Alexandre Lemaire Saeven

View GitHub Profile
@Saeven
Saeven / gist:9740815
Created March 24, 2014 14:10
Where oh where does the break_chain_on_failure go?
$recaptcha = new Captcha\ReCaptcha();
$recaptcha
->setOption( 'theme', $theme )
->setPubKey( '6Ld-&hl='.$lang)
->setPrivKey( '6Ld-' )
->setMessage( _( "Correctly repeat the text in the image, in the box beneath it" ) );
$captcha = new Element\Captcha( 'captcha' );
$captcha
@Saeven
Saeven / gist:bb5a95c27afbc186cdb8
Created May 23, 2014 13:52
Possible to switch a route?
$sem->attach('Zend\Mvc\Application', MvcEvent::EVENT_ROUTE, function( MvcEvent $ev) use($sm,$em) {
$rm = $ev->getRouteMatch()->getMatchedRouteName();
if( getenv("environment") === "master" && $rm == 'zfcuser' )
{
$ev->setRouteMatch( /* switch the route out here */ );
}
});
$(document).ready( function(){
if( $.cookie('welcome_register') )
{
// show the thanks div
$.removeCookie('welcome_register', { path: '/' });
}
});
@Saeven
Saeven / gist:c953630d37ed57028c85
Created July 21, 2014 19:22
PHP DynamoDB Poll using Zend Framework 2
<?php
namespace Application\Controller;
use Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Enum\ComparisonOperator;
use Aws\DynamoDb\Enum\Type;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\JsonModel;
use Zend\View\Model\ViewModel;
-webkit-box-shadow: 0px 0px 15px 3px rgba(50, 50, 50, 0.8);
-moz-box-shadow: 0px 0px 15px 3px rgba(50, 50, 50, 0.8);
box-shadow: 0px 0px 15px 3px rgba(50, 50, 50, 0.8);
$("#sort").on('change', function( e ){
var sort = $(this).val();
$("div#collage").empty();
$("div#collage").spin('show');
$.get( '/redeem/sweeps/sort', { 'sort': sort }, function( data ){
$("div#collage").html( data );
Ladda.bind( 'button.ladda-button' );
});
@Saeven
Saeven / gist:da7a1a085da381589401
Created October 24, 2014 14:28
Dynamically Substitute template in ZF2
$eventManager->attach( MvcEvent::EVENT_DISPATCH, function( MvcEvent $e ){
$route_name = 'something';
$new_template = 'something-else';
if( $e->getRouteMatch() && $e->getRouteMatch()->getMatchedRouteName() == $route_name )
$e->getViewModel()->setTemplate( $new_template );
});
@Saeven
Saeven / ZF 2.4 PHPUnit Bootstrap
Created April 6, 2015 21:27
Lets you use your application config as though you were in-app.
<?php
namespace ApplicationTest;
use Zend\Loader\AutoloaderFactory;
use Zend\Mvc\Service\ServiceManagerConfig;
use Zend\ServiceManager\ServiceManager;
use RuntimeException;
error_reporting(E_ALL | E_STRICT);
/**
* Class UserFormFactory
* @package CirclicalUser\Factory\Form
*/
class UserFormFactory implements FactoryInterface, MutableCreationOptionsInterface
{
/**
* @var array
*/
@Saeven
Saeven / Bootstrap.php
Last active August 29, 2015 14:24
Adjusted Bootstrap for ZF 2.5 that goes straight to zend-loader rather than the old autoloader factory path.
protected static function initAutoloader()
{
$vendorPath = static::findParentPath('vendor');
if (file_exists($vendorPath . '/autoload.php')) {
include $vendorPath . '/autoload.php';
}
include $vendorPath . '/zendframework/zend-loader/src/AutoloaderFactory.php';
AutoloaderFactory::factory(array(