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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$agreement = new HackAgreement(); | |
// ... | |
$agreement->create($apiContext); | |
//////////// | |
use PayPal\Api\Agreement; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo | |
{ | |
private $foo; | |
private $bar; | |
private $baz; | |
} | |
$hydrator = function(array $data) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DateToStringTransformer implements DataTransformerInterface | |
{ | |
/** | |
* @param mixed $value | |
* @return mixed|void | |
*/ | |
public function transform($value) | |
{ | |
if (!$value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace ChubProduction\Bundle\XXXBundle\Tests; | |
/** | |
* TwigExtensionTestCase | |
* | |
* @author Vladimir Chub <[email protected]> | |
*/ | |
trait TwigExtensionTestCase | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
mine.twig_string_loader: | |
class: "Twig_Loader_String" | |
mine.twig_string: | |
class: "%twig.class%" | |
arguments: [@mine.twig_string_loader, %twig.options% ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FormType extends AbstractType | |
{ | |
// .... | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
$builder->add('field') | |
->add(....) | |
->addEventListener(FormEvents::POST_BIND, array($this, 'postBind')); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace NSBundle\Repo; | |
use Symfony\Component\DependencyInjection\Container; | |
class MyRepository | |
{ | |
public function __construct(Container $c) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
/** |