Skip to content

Instantly share code, notes, and snippets.

@webdevilopers
webdevilopers / AbstractFormAutocomplete.php
Last active August 29, 2015 14:03
Abstract Autocomplete Form View Helper ZF2 issue #4221
<?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 August 29, 2015 14:03
Doctrine Debug dump usage instead of var_dump
<?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 August 29, 2015 14:03
ZF2 How to add fieldset to form and remove element from it
<?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 July 15, 2014 12:27
ZfcRbac assertion example using factories
<?php
namespace Application\Assertions;
use ZfcRbac\Assertion\AssertionInterface;
use ZfcRbac\Service\AuthorizationService;
class CanEditContractAssertion implements AssertionInterface
{
/**
@webdevilopers
webdevilopers / sf2_controller.php
Last active August 29, 2015 14:04
Client cURL multipart form-data POST to JasperReportsEngine Servlet
<?php
namespace Plusquam\Bundle\ContractBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
class BundleController extends Controller
{
public function egzAction()
{
@webdevilopers
webdevilopers / ContractState.php
Last active August 29, 2015 14:04
Symfony2 (static) Translation with Doctrine Extensions using Gedmo or / and Stof and messages.locale.domain
<?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 August 29, 2015 14:05
MySQL - Join row to get latest change in one single row
--
-- Database: `webdevilopers`
--
-- --------------------------------------------------------
--
-- Table structure for table `contracts`
--
@webdevilopers
webdevilopers / alternative_performant_having_query.sql
Last active August 29, 2015 14:05
MySQL perfomance impact on COUNT DISTINCT when adding subquery to WHERE condition with 20000 rows in parent table
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 September 17, 2014 13:41
Add fullText (WHERE LIKE OR) with SonataDoctrineORMAdminBundle search to datagridFilters in SonataAdminBundle
<?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 September 18, 2014 12:13
Single and Multiple Ordering To-Many Associations in Doctrine2
/**
* @ORM\Entity
* @ORM\Table(name="branches")
*/
class Branch
{
/**
* @ORM\OneToMany(targetEntity="Application\Sonata\UserBundle\Entity\User", mappedBy="branch")
* @ORM\OrderBy({"lastName" = "ASC", "firstName" = "ASC"})
*/