Skip to content

Instantly share code, notes, and snippets.

View localheinz's full-sized avatar

Andreas Möller localheinz

View GitHub Profile
@localheinz
localheinz / menu.phtml
Created December 11, 2012 15:18
Navigation view helper plugin prepends the normalised name of the plugin to the id of a page, if specified
<?php /* @var $container Zend\Navigation\Navigation */ ?>
<?php if ($container->hasPages()): ?>
<ul>
<?php foreach ($container->getPages() as $page): ?>
<?php /* @var $page Zend\Navigation\Page\AbstractPage */ ?>
<?php if ($page->isVisible()): ?>
<li><?php echo $this->navigation()->menu()->htmlify($page); ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
@localheinz
localheinz / Module.php
Created December 20, 2012 20:25
Example of how to wire up a database adapter with ZF2
<?php
// module/MyNamespace/Module.php
namespace MyNamespace;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\ServiceManager\ServiceManager;
@localheinz
localheinz / User.php
Last active December 10, 2015 01:34
Translation of validation error messages
<?php
/**
* Please be aware that __($messageId) is just as function that returns $messageId - it is used for gettext to pick up
* message ids.
*/
$this->inputFilter
->add(array(
'name' => 'firstname',
'validators' => array(
@localheinz
localheinz / example.html
Created February 7, 2013 12:22
As in your email.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/asset/css/styles.less">
</head>
<body>
<div class="container">
<div class="row">
<div class="span4">
#!/usr/bin/env php
<?php
$changes = [];
exec(
'git diff --cached --name-status --diff-filter=ACM',
$changes
);
### Keybase proof
I hereby claim:
* I am localheinz on github.
* I am localheinz (https://keybase.io/localheinz) on keybase.
* I have a public key whose fingerprint is 988E 9FE9 A7F1 3DD6 9FD2 9F0F 3A04 5C98 08E7 46DD
To claim this, I am signing this object:
@localheinz
localheinz / FooTest.php
Last active August 29, 2015 14:13
How can you mark a test as skipped if the annotated data provider returns an empty array?
<?php
namespace Foo;
class BarTest extends PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (null === $this->providerBaz()) {
@localheinz
localheinz / keybase.md
Created April 8, 2016 15:05
keybase.md

Keybase proof

I hereby claim:

  • I am localheinz on github.
  • I am localheinz (https://keybase.io/localheinz) on keybase.
  • I have a public key ASDTAW1l_75Ox6sSn-zaqbAzJdM34x_z9HObGxv7w7cm1Ao

To claim this, I am signing this object:

@localheinz
localheinz / Meagrams.php
Created February 20, 2017 11:16
Meagram Solution (PHP)
<?php
declare(strict_types=1);
final class Meagrams
{
/**
* @var string[]
*/
private $words;
@localheinz
localheinz / FullDeck.php
Created February 20, 2017 11:23
Full Decks Solution (PHP)
<?php
declare(strict_types=1);
final class FullDeck
{
public function cards(): array
{
static $cards;