Skip to content

Instantly share code, notes, and snippets.

View basz's full-sized avatar

Bas Kamer basz

View GitHub Profile
$accept = $headers->get('Accept');
$match = $accept->match('application/json, application/javascript, application/rss+xml, application/atom+xml');
var_dump($match);
object(Zend\Http\Header\Accept\FieldValuePart\AcceptFieldValuePart)[301]
private 'internalValues' (Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePart) =>
object(stdClass)[302]
public 'typeString' => string '*/*' (length=3)
public 'type' => string '*' (length=1)
goal = get filtermanager to act as plugin manager and have invokables and factories for all of the assetic filters and thus have a generic way to configure those filters.
a call to
$filterManager->setFilters($path, AssetInterface $asset)
must be able to hanlde the following configuration settings.
<?php
namespace SndCompositionTool\Form;
use SndCompositionTool\Entity\PreOrder as PreOrderEntity;
use Zend\Form\Form;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterProviderInterface;
use Zend\Stdlib\Hydrator\ObjectProperty as Hydrator;
/**
* @return array
*/
public function getInputFilterSpecification()
{
$hostname = new \Zend\Validator\Hostname();
$hostname->setMessages(
array(
<?php
namespace SndAdmin\Entity;
use Doctrine\ORM\Mapping as ORM;
use ZfcUser\Entity\UserInterface;
/**
* @ORM\Entity
<?php
namespace SndAdmin\Service\Form;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Form\FormFactoryAwareInterface;
use Zend\Form\Factory;
use SndAdmin\Form\DealerForm as Form;
public function findAround(Point $point, $radius = 1) {
$em = $this->getEntityManager();
$qb = $em->createQueryBuilder();
$qb->select('m as marker, (DISTANCE(m.location, POINT_STR(:point))) as distance')
->from('SndSpecialistLocator\Entity\Marker', 'm')
->where('DISTANCE(m.location, POINT_STR(:point)) < :distance')
->setParameter('point', $point)
->orderBy('distance', 'ASC')
->setParameter('distance', $radius);
@basz
basz / gist:4149878
Created November 26, 2012 18:48
Better way
When an accountNumber has been changed in the form it must be validated for uniqueness. This unique validator can't be used when the value hasn't been modified, because the value isn't unique then... I'm aware that I might write a custom validator, but my question is how do you handle dynamic input filtering on a form. A form for new record probably has different filters then while modifying.
I'm also aware of the validation groups, do those help in this situation?
function editAction() {
...
if ($this->getRequest()->isPost()) {
$form->setData($this->getRequest()->getPost());
if ($entity->getAccountNumber() != $form->get('dealer')->get('accountNumber')->getValue()) {
public function fetchQuery(\Zend\Http\PhpEnvironment\Request $request = null) {
$qb = $this->_em->createQueryBuilder();
$qb->select('entity, contact, address')
->from('SndAdmin\Entity\Dealer', 'entity')
->leftJoin('entity.contact', 'contact' )
->leftJoin('entity.shippingAddress', 'address' );
if (isset($options['offset'])) {
$qb->setFirstResult( $options['offset'] );
$user = new \SndAdmin\Entity\User();
$role = new \SndAdmin\Entity\UserRole();
$role->setRole('loser');
$user->setRole($role);
$em->persist($user);
$em->flush();