Skip to content

Instantly share code, notes, and snippets.


Vladimir Chub ChubV

View GitHub Profile
ChubV / Paypal.php
Created Jul 20, 2018
NotifyUrl workaround
View Paypal.php
$agreement = new HackAgreement();
// ...
use PayPal\Api\Agreement;

Application level restrictions and domain contracts check.

Validation and all kinds of restrictions may be significant part of your application. And it is important to understand the difference between application level restrictions and domain contracts checks. So in this article I'm going to share my view on validation. It will be helpful for those who started practicing domain-driven design principles in their projects, but still too coupled in their minds to framework/application style of developing.

View hydrate.php
class Foo
private $foo;
private $bar;
private $baz;
$hydrator = function(array $data) {
View DateToStringTransformer.php
class DateToStringTransformer implements DataTransformerInterface
* @param mixed $value
* @return mixed|void
public function transform($value)
if (!$value) {
ChubV / TwigExtensionTestCase.php
Created Jul 10, 2013
Twig extension test case
View TwigExtensionTestCase.php
namespace ChubProduction\Bundle\XXXBundle\Tests;
* TwigExtensionTestCase
* @author Vladimir Chub <>
trait TwigExtensionTestCase
ChubV / twig.yml
Created Jun 26, 2013
Twig string
View twig.yml
class: "Twig_Loader_String"
class: "%twig.class%"
arguments: [@mine.twig_string_loader, %twig.options% ]
ChubV / PaginationSubscriber.php
Last active Dec 11, 2015
Add DBAL QueryBuilder support for KnpPaginatorBundle
View PaginationSubscriber.php
namespace ChubV\ToolkitBundle\Subscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Knp\Component\Pager\Event\ItemsEvent;
use Doctrine\DBAL\Query\QueryBuilder;
class PaginationSubscriber implements EventSubscriberInterface
public function items(ItemsEvent $event)
ChubV / FormType.php
Created Nov 29, 2012
Set form values after bind
View FormType.php
class FormType extends AbstractType
// ....
public function buildForm(FormBuilderInterface $builder, array $options)
->addEventListener(FormEvents::POST_BIND, array($this, 'postBind'));
View MyRepository.php
namespace NSBundle\Repo;
use Symfony\Component\DependencyInjection\Container;
class MyRepository
public function __construct(Container $c)
View CroppedThumbFilterLoader.php
namespace ChubProduction\Bundle\SiteBundle\Imagine;
use Imagine\Image\Box;
use Imagine\Image\Point;
use Imagine\Filter\Transformation;
use Avalanche\Bundle\ImagineBundle\Imagine\Filter\Loader\LoaderInterface;
use Imagine\Image\ManipulatorInterface;