Skip to content

Instantly share code, notes, and snippets.

@webdevilopers
webdevilopers / AbstractFormAutocomplete.php
Last active Aug 29, 2015
Abstract Autocomplete Form View Helper ZF2 issue #4221
View AbstractFormAutocomplete.php
<?php
namespace Application\Form\View\Helper;
use Zend\Form\View\Helper\FormText;
use Zend\Form\ElementInterface as ElementInterface;
class AbstractFormAutocomplete extends FormText
{
protected $foo;
@webdevilopers
webdevilopers / DoctrineDebugDump.php
Last active Aug 29, 2015
Doctrine Debug dump usage instead of var_dump
View DoctrineDebugDump.php
<?php
/**
* Lazy load proxies always contain an instance of Doctrine’s EntityManager and all its dependencies.
* Therefore a var_dump() will possibly dump a very large recursive structure which is impossible to render and read.
* You have to use Doctrine\Common\Util\Debug::dump() to restrict the dumping to a human readable level.
* Additionally you should be aware that dumping the EntityManager to a Browser may take several minutes,
* and the Debug::dump() method just ignores any occurrences of it in Proxy instances.
*/
#var_dump($entity); // will possibly dump a very large recursive structure which is impossible to render and read
@webdevilopers
webdevilopers / CreateContactForm.php
Last active Aug 29, 2015
ZF2 How to add fieldset to form and remove element from it
View CreateContactForm.php
<?php
namespace Application\Form;
use Zend\Form\Form;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class CreateContractForm extends Form
implements ServiceLocatorAwareInterface
{
@webdevilopers
webdevilopers / CanEditContractAssertion.php
Created Jul 15, 2014
ZfcRbac assertion example using factories
View CanEditContractAssertion.php
<?php
namespace Application\Assertions;
use ZfcRbac\Assertion\AssertionInterface;
use ZfcRbac\Service\AuthorizationService;
class CanEditContractAssertion implements AssertionInterface
{
/**
@webdevilopers
webdevilopers / sf2_controller.php
Last active Aug 29, 2015
Client cURL multipart form-data POST to JasperReportsEngine Servlet
View sf2_controller.php
<?php
namespace Plusquam\Bundle\ContractBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
class BundleController extends Controller
{
public function egzAction()
{
@webdevilopers
webdevilopers / ContractState.php
Last active Aug 29, 2015
Symfony2 (static) Translation with Doctrine Extensions using Gedmo or / and Stof and messages.locale.domain
View ContractState.php
<?php
namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;
/**
* @ORM\Entity
@webdevilopers
webdevilopers / dump.sql
Last active Aug 29, 2015
MySQL - Join row to get latest change in one single row
View dump.sql
--
-- Database: `webdevilopers`
--
-- --------------------------------------------------------
--
-- Table structure for table `contracts`
--
@webdevilopers
webdevilopers / alternative_performant_having_query.sql
Last active Aug 29, 2015
MySQL perfomance impact on COUNT DISTINCT when adding subquery to WHERE condition with 20000 rows in parent table
View alternative_performant_having_query.sql
SELECT COUNT(DISTINCT a.angebot_id),
ash.angebot_status_datum,
(
SELECT MAX(ash2.angebot_status_datum)
FROM angebot_status_historie ash2
WHERE ash2.angebot_id = a.angebot_id
) AS current_state
FROM
angebot a
JOIN angebot_status_historie ash USING (angebot_id)
@webdevilopers
webdevilopers / UserAdmin.php
Created Sep 17, 2014
Add fullText (WHERE LIKE OR) with SonataDoctrineORMAdminBundle search to datagridFilters in SonataAdminBundle
View UserAdmin.php
<?php
namespace Application\Sonata\UserBundle\Admin;
use Sonata\UserBundle\Admin\Model\UserAdmin as SonataUserAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
class UserAdmin extends SonataUserAdmin
{
protected function configureDatagridFilters(DatagridMapper $filterMapper)
@webdevilopers
webdevilopers / multiple_ordering.php
Created Sep 18, 2014
Single and Multiple Ordering To-Many Associations in Doctrine2
View multiple_ordering.php
/**
* @ORM\Entity
* @ORM\Table(name="branches")
*/
class Branch
{
/**
* @ORM\OneToMany(targetEntity="Application\Sonata\UserBundle\Entity\User", mappedBy="branch")
* @ORM\OrderBy({"lastName" = "ASC", "firstName" = "ASC"})
*/