Skip to content

Instantly share code, notes, and snippets.

View manuakasam's full-sized avatar

Manuel St. manuakasam

  • Germany, NRW, Duisburg
View GitHub Profile
public function fetchAll()
{
$sqlSelect = $this->tableGateway->select(function (Select $select) {
$select->where(array(
"name_de" => "Default"
));
$select->order('name_de DESC');
});
@manuakasam
manuakasam / OneToOneHydrator.php
Created March 14, 2015 17:20
See class header. A basic hydration component to easily deliver OneToOne Hydrations for entities without much development time.
<?php
/**
* @author Manuel Stosic <manuel.stosic@krankikom.de>
*/
namespace Zf2demo\Hydrator;
use Zend\Stdlib\Hydrator\ClassMethods;
/**
'filters' => [ 'invokables' => [ 'fooFilter' => 'My\Namespace\FooFilter']]
class FooFilter implements FilterInterface
{
public function filter($str) {
$str = magic_happens($str);
return $str;
}
}
<?php
class HelperFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $sl)
{
$realSL = $sl->getServiceLocator();
$repository = $realSL->get('Doctrine\ORM\EntityManager')->getRepository('My\Repository');
return new MyHelper($repository);
@manuakasam
manuakasam / gist:9136505
Created February 21, 2014 15:41
bootstrap flashmessender config
'view_helper_config' => [
'flashmessenger' => [
'message_open_format' => '<div%s><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><ul><li>',
'message_close_string' => '</li></ul></div>',
'message_separator_string' => '</li><li>'
]
],
@manuakasam
manuakasam / gist:9089089
Created February 19, 2014 09:57
I love ::class
'zfc_rbac' => [
'identity_provider' => UserService::class
],
'controllers' => [
'factories' => [
LoginController::class => LoginControllerFactory::class,
LogoutController::class => LogoutControllerFactory::class,
DetailController::class => DetailControllerFactory::class
]
],
'router' => [
'routes' => [
'sam-rfc' => [
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => [
'route' => '/sam-rfc',
'defaults' => [
'controller' => 'SamRfc\Controller\IndexController',
'action' => 'index'
]
$this->blocks('startbody')
ViewHelper::__invoke($part = 'startbody')
ViewHelper->getBlockService()->findBlock($part)
BlockService->findBlock($part)
BlockService->getBlockRepository->findBy('part', $part)
#!/bin/bash
# Try and get debian operating system
# id, codename, and release
TYPE=$(echo "$1" | tr '[A-Z]' '[a-z]')
OS=$(uname)
ID="unknown"
CODENAME="unknown"
RELEASE="unknown"
@manuakasam
manuakasam / EntitiesFromToday
Created November 23, 2013 12:58
I got a couple of understanding problems. 1) How to fetch Entities that have to match multiple criterias? 2) How to fetch all enabled users from today from a certain user? -
class EntitiesFromToday extends Criteria
{
public function __construct(Expression $expression = null, array $orderings = null, $firstResult = null, $maxResults = null)
{
parent::__construct($expression, $orderings, $firstResult, $maxResults);
$this->andWhere(
$this->expr()->qt(
'published',
new \DateTime('-1 day')