Skip to content

Instantly share code, notes, and snippets.

View bakura10's full-sized avatar

Michaël Gallego bakura10

View GitHub Profile
<?php
return array(
'zfr_cors' => array(
array(
'rule' => '*',
'allowed_origins' => array(),
'allowed_methods' => array(),
// ...
),
{
"Statement": [
{
"Sid": "Stmt1368092872690",
"Action": [
"elasticbeanstalk:Terminate*",
"elasticbeanstalk:Delete*"
],
"Effect": "Deny",
"Resource": [
<?php
// In the InputCollection class, I have this.
// Basically, the issue is that when user called "validate", it should returns a "ValidationResult" object. However,
// this method needs to recursively calls each children input collection. BUT I don't want the children input filter to
// return a validation result, instead I want them return a simple array of error messages, that will be aggregated by
// the top input collection.
//
// I've thought about having validate(array $data, $context = null, $buildValidationResult = false);
// But it's ugly
@bakura10
bakura10 / test.php
Last active December 22, 2015 03:39
<?php
// I need to get a specific key of the array (for instance "c"), and then be able FROM THIS new array,
// go back to the previous level
$data = array(
'a' => 'aaaa',
'b' => 'bbbb',
'c' => array(
'd' => 'dddd',
class ServiceManager
{
protected $cache = array();
protected $factories = array();
public function create($name)
{
if (isset($this->factories[$name]) && !isset($this->cache[$name])) {
$this->cache[$name] = $this->factories[$name]->createService($this);
<?php
class CompiledFactory2 implements FactoryInterface
{
public function createService(ServiceLocatorInterface $sl)
{
$a = new A();
$b = $sl->get('A');
return new B(a);
}
<?php
class PluginManagerFactory implements FactoryInterface
{
public function createService(ServiceLocator $locator, $requestedName)
{
// $requestedName is "SlmQueue\Job\JobPluginManager"
$pluginManager = new $requestedName();
$configPath = $pluginManager->getConfigPath();
/** @var InputInterface $input */
foreach ($validationRecursiveIterator as $name => $input) {
$input->setValue(isset($data[$name]) ? $data[$name] : null);
if ($input->isValid($context)) {
continue;
}
$errorMessages[$name] = $input->getErrorMessages();
<?php
/**
* This is the config file for ZfrRest. Just drop this file into your config/autoload folder (don't
* forget to remove the .dist extension from the file), and configure it as you want
*/
return array(
'zfr_rest' => array(
/**
<?php
class MyFieldset extends Fieldset implements InputFilterProviderInterface
{
public function __construct()
{
parent::__construct();
$this->add(array(
'type' => 'Email',
'name' => 'email'