Skip to content

Instantly share code, notes, and snippets.

View cystbear's full-sized avatar
🚴‍♂️
🏄🏕️

Oleg Zinchenko cystbear

🚴‍♂️
🏄🏕️
View GitHub Profile
@cystbear
cystbear / FeatureContext.php
Created November 16, 2011 20:24
Behat meta steps -- tiny example
<?php
/**
* @Given /^I logged in as "([^"]*)" with "([^"]*)" password$/
*/
public function iLoggedInAsWithPassword($username, $password)
{
return array(
new Step\Given("I am on \"/login\""),
new Step\When("I fill in \"Username\" with \"$username\""),
<?php
class DefaultController extends Controller
{
/**
* Dashboard page.
* @Permissions(perm="dashboard_view")
* @Route("/", name="ITEDashboardBundle_index")
* @Template()
* @return array
@cystbear
cystbear / ExceptionalClient.php
Created January 18, 2012 16:49 — forked from everzet/ExceptionalClient.php
View real exceptions in Behat output with Mink+SymfonyDriver in your Symfony2 feature suite
<?php
namespace Your\MainBundle;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Component\HttpKernel\HttpKernelInterface;
class ExceptionalClient extends Client
{
static private $catchExceptions = true;
@cystbear
cystbear / buzz.yml
Created April 25, 2012 11:03
Config example to substitute SensioBuzzBundle
parameters:
buzz.curl.class: Buzz\Client\Curl
buzz.file_get_contents.class: Buzz\Client\FileGetContents
buzz.browser_curl.class: Buzz\Browser
services:
buzz.curl:
class: %buzz.file_get_contents.class%
arguments: []
calls:
<?php
$phpLogsEater = <<<ASCII
| :|
| |
| .|
____| .|
.' . ). ,'
.' c '7 ) (
_.-" |.' `.
<?php
namespace Acme\Calculator;
class Calculator
{
public $a;
public $b;
public function __construct($a, $b)

Domain Model

How It Works

Putting a Domain Model in an application involves inserting a whole layer of objects that model the business area you're working in. You'll find objects that mimic the data in the business and objects that capture the rules the business uses. Mostly the data and process are combined to cluster the processes close to the data they work with.

An OO domain model will often look similar to a database model, yet it will still have a lot of differences. A Domain Model mingles data and process, has multivalued attributes and a complex web of associations, and uses inheritance.

@cystbear
cystbear / bind-to.php
Last active April 23, 2020 08:26
Shifter Domain -> DTO
<?php
class Domain
{
protected $foo;
protected $bar;
protected $baz;
public function setFoo($foo)
{
@cystbear
cystbear / services.xml
Created January 13, 2014 15:42
Doctrine MongoDB ODM Param Converter
<service id="doctrine.odm.param_converter" class="Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter">
<tag name="request.param_converter" converter="doctrine.odm" />
<argument type="service" id="doctrine_mongodb"/>
</service>
@cystbear
cystbear / DynamicRoleHierarchy.php
Last active March 6, 2018 14:53
Example of DynamicRoleHierarchy, how to fetch roles stored in DB and use them in regular Symfony2 security component
<?php
namespace Acme\SecurityBundle\Role;
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
use Symfony\Component\Security\Core\Role\RoleHierarchy;
use Acme\SecurityBundle\Entity\RoleRepository;
class DynamicRoleHierarchy implements RoleHierarchyInterface