Skip to content

Instantly share code, notes, and snippets.

webdevilopers / CompartmentFilter.php
Created Feb 26, 2015
Doctrine ORM custom Aware Filter and Event in Symfony
View CompartmentFilter.php
namespace Plusquam\Bundle\ContractBundle\Filter;
use Doctrine\ORM\Query\Filter\SQLFilter;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\Common\Annotations\Reader;
class CompartmentFilter extends SQLFilter
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
* @ORM\Entity()
* @ORM\EntityListeners({"Acme\AppBundle\Event\CustomerListener"})
class Customer()
webdevilopers / ErrorResponseBuilder.php
Last active Jul 30, 2021
API friendly error handling with Symfony Messenger and Event Listener
View ErrorResponseBuilder.php
namespace Acme\Common\Infrastructure\Symfony\Messenger;
use Prooph\EventStore\Exception\ConcurrencyException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Messenger\Exception\HandlerFailedException;
use Symfony\Component\Messenger\Exception\RuntimeException;
use Symfony\Component\Messenger\Exception\ValidationFailedException;
webdevilopers / RecentContractsBlockService.php
Last active Jun 3, 2021
Sonata Admin - Include custom block / list view in edit template
View RecentContractsBlockService.php
namespace Plusquam\Bundle\ContractBundle\Block;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Response;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
webdevilopers / CalculationController.php
Created Mar 27, 2016
How to use optional ParamConverter with null default in Route in Symfony Controller
View CalculationController.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 / Upcaster.php
Last active Jan 8, 2021
Attach upcaster to Prooph Event Store
View Upcaster.php
namespace Acme\Common\Infrastructure\Prooph\EventStore;
use Prooph\Common\Messaging\Message;
use Prooph\EventStore\Upcasting\SingleEventUpcaster;
final class Upcaster extends SingleEventUpcaster
public function upcast(Message $message): array
webdevilopers / DefaultController.php
Last active Oct 31, 2020
Sending JWT Token in Guzzle POST with LexikJWTAuthenticationBundle
View DefaultController.php
namespace AppBundle\Controller;
class DefaultController extends Controller
* @Route("/gettoken")
public function getToken()
webdevilopers / PersonListProjection.php
Created Oct 29, 2020
Prooph Event Stream Projection from merged streams event ordering
webdevilopers / AbstractDormerPriceQuote.php
Last active Oct 2, 2020
Symfony Assert Annotations using external Class constants
View AbstractDormerPriceQuote.php
namespace Sps\Bundle\PriceQuoteBundle\Entity;
abstract class AbstractDormerPriceQuote
extends PriceQuoteRequest
const MIN_ROOF_PITCH = 10;
const MAX_ROOF_PITCH = 55;
webdevilopers / EmploymentContract.php
Last active Aug 30, 2020
Merge event-sourced aggregate roots (A+ES) by passing read model / decision model
View EmploymentContract.php
final class EmploymentContract extends AggregateRoot
* @param Details $contractToMerge
* This contract is always the initial contract and the oldest one.
* Since the contract to merge is always newer it always overwrites the current state.
public function mergeWith(Details $contractToMerge): void