Skip to content

Instantly share code, notes, and snippets.

@webdevilopers
webdevilopers / ChangeInspectionDetails.php
Last active Jun 24, 2016
Using PHP7 type hinting with Symfony Form Text Type and empty_data returning NULL
View ChangeInspectionDetails.php
<?php
class ChangeInspectionDetails extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('problemNumber', TextType::class, [
'empty_data' => '' // no effect
]);
@webdevilopers
webdevilopers / AddDefectHandler.php
Last active May 18, 2016
How to handle events from recorder with SimpleBus in Symfony
View AddDefectHandler.php
<?php
class AddDefectHandler
implements MessageHandler
{
/**
* @var RecordsMessages $eventRecorder
*/
private $eventRecorder;
@webdevilopers
webdevilopers / Customer.php
Last active Aug 17, 2021
Using event subscriber to get MongoDB ODM Documents related to ORM Entity in Doctrine
View Customer.php
<?php
/**
* @ORM\Entity()
* @ORM\EntityListeners({"Acme\AppBundle\Event\CustomerListener"})
*/
class Customer()
{
}
@webdevilopers
webdevilopers / CalculationController.php
Created Mar 27, 2016
How to use optional ParamConverter with null default in Route in Symfony Controller
View CalculationController.php
<?php
namespace Sps\Bundle\CalculationBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
class CalculationController extends Controller
{
@webdevilopers
webdevilopers / ContractController.php
Last active Mar 18, 2016
Inject Token Storage into Command
View ContractController.php
<?php
namespace Plusquam\Bundle\ContractBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Response;
use Plusquam\Bundle\ContractBundle\Entity\Contract;
@webdevilopers
webdevilopers / Contract.php
Last active Mar 16, 2016
Entities passed to the choice field must be managed
View Contract.php
<?php
namespace Plusquam\Bundle\ContractBundle\Entity;
use Plusquam\Bundle\ContractBundle\Entity\Person;
use Plusquam\Bundle\ContractBundle\Entity\SupplierContact;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
View 0a1080967eab56170116d855cfe10ff35194d7f9a36aa8bb796854fdd145c756.php
<?php
/* SonataAdminBundle:CRUD:base_acl_macro.html.twig */
class __TwigTemplate_50e0a0acb6692fad6ee6016b2f0882c3bfad1420f2afa41ee25fbcb5d97dcbb3 extends Twig_Template
{
public function __construct(Twig_Environment $env)
{
parent::__construct($env);
$this->parent = false;
@webdevilopers
webdevilopers / bootstrap_3_horizontal_layout.html.twig
Created Mar 2, 2016
Override label class in Bootstrap 3 horizontal layout in Symfony Twig Bridge
View bootstrap_3_horizontal_layout.html.twig
{% use "bootstrap_3_layout.html.twig" %}
{% block form_start -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %}
{{- parent() -}}
{%- endblock form_start %}
{# Labels #}
{% block form_label -%}
@webdevilopers
webdevilopers / AbstractCreateCalculationHandler.php
Last active Apr 15, 2016
Domain Driven Design Command Bus and Handler example in Symfony
View AbstractCreateCalculationHandler.php
<?php
namespace Sps\Bundle\CalculationBundle\Handler;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Translation\Translator;
use Sps\Bundle\CalculationBundle\Entity\DormerCalculationPrice;
@webdevilopers
webdevilopers / Controller.php
Last active Nov 16, 2019
Symfony - Inject Session Flash Bag into Service with output and translation in TWIG via app.session
View Controller.php
<?php
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
/**
* @Route("/")
* @Template()
*/