Skip to content

Instantly share code, notes, and snippets.

View dmitrybelyakov's full-sized avatar

Dmitry Belyakov dmitrybelyakov

View GitHub Profile
@dmitrybelyakov
dmitrybelyakov / bootstrap.php
Created February 29, 2012 11:54
Bootstrap phpunit
<?php
ini_set("display_errors", 1);
chdir(dirname(__DIR__) . '/../../');
require_once 'vendor/.composer/autoload.php';
$appConfig = include 'config/application.config.php';
$listenerOptions = new Zend\Module\Listener\ListenerOptions($appConfig['module_listener_options']);
$defaultListeners = new Zend\Module\Listener\DefaultListenerAggregate($listenerOptions);
$defaultListeners->getConfigListener()->addConfigGlobPath('config/autoload/*.config.php');
@dmitrybelyakov
dmitrybelyakov / FailingTest.php
Created February 29, 2012 11:55
Bootstrap phpunit
<?php
require_once ('PHPUnit/Autoload.php');
class FailingTest extends \PHPUnit_Framework_TestCase
{
public function testTestThatWeJustFail()
{
$this->assertTrue(true);
}
'view_helpers' => array(
'invokables' => array(
'currentlocale' => 'ShiftKernel\Locale\ViewHelper\Locale',
),
'factories' => array(
'currentlocale' => function($sm) {
return new \ShiftKernel\Locale\ViewHelper\Locale(
$sm->get('ShiftKernel\Locale\LocaleService')
);
},
//action helpers (controller plugins)
'controller_plugins' => array(
'invokables' => array(
'isAllowed' => 'ShiftUser\Access\ActionHelper\IsAllowed'
),
'factories' => array(
'ShiftUser\Access\ActionHelper\IsAllowed' => function($sm){
$class = new \ShiftUser\Access\ActionHelper\IsAllowed($sm);
$class->createByFactory();

Looking for a way to define a view helper via configuration. That helper should be created via callback factory and have a dependency injected in constructor, as per documentation here: Registering Helpers

So there we go with a helper itself:

class Locale extends AbstractHelper
{

    protected $localeService;
/**
* Construct
* Instantiates the form and configures input fields
*
* @return void
*/
public function __construct($name, array $options = array())
{
//init
parent::__construct($name, $options);
@dmitrybelyakov
dmitrybelyakov / Controller.php
Created March 6, 2014 07:58
Bind entity to form with fieldsets
<?php
/**
* Example action
* This is an example action that tests binding of forms to entities.
* @return \Zend\View\Model\ViewModel
*/
public function exampleAction()
{
$node = new ArrayObject(array(
#!/bin/bash
# Make sure we have the dev tools
yum groupinstall "Development Tools"
# Just in case you started installing dependencies from yum
yum -y remove libnfnetlink
# lets put the source code here
mkdir -p ~/.src
@dmitrybelyakov
dmitrybelyakov / pedantically_commented_playbook.yml
Created October 26, 2015 11:14 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.