Skip to content

Instantly share code, notes, and snippets.

@codeliner
codeliner / bc_interaction_sample.php
Created April 15, 2014 13:06
Sample to show interaction between two bounded contexts
<?php
/**
* This file is an example gist to show the interaction between an ArticleContext and a LikeContext
*
* @example:
*
* We have to bounded contexts: ArticleContext and LikeContext and show the simplified process of following use case:
*
* In order to create a valid article Like, I should validate the article ID given to the LikeContext.
*
@maxgalbu
maxgalbu / Switch_Node.php
Last active December 31, 2019 16:03
Switch tag for Twig, updated from https://github.com/fabpot/Twig/pull/185 to work with Twig >= 1.12
<?php
//To be added under Twig/Node/Switch.php
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) 2009 Armin Ronacher
*
@jasonhofer
jasonhofer / doctrine-dql-type-function.php
Last active December 30, 2021 21:11
Doctrine TYPE() function for DQL. Provides a way to access an entity's discriminator field in DQL queries.
<?php
namespace My\Doctrine\ORM\Query\Functions;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\QueryException;
use Doctrine\ORM\Query\SqlWalker;
@satooshi
satooshi / DirectoryStructure
Last active September 26, 2021 20:03
Directory structure of Domain Driven Design application with Symfony2, Doctrine2.
sf2-ddd
├── app
├── bin
├── build
├── lib
├── src
│   └── __VendorPrefix
│   ├── Application
│   │   └── __DomainNameBundle
│   │   ├── Command
@romaricdrigon
romaricdrigon / formController.js
Created August 21, 2013 07:46
Using AngularJS on Symfony2 forms
// An example controller binded to the form
function FormCntl($scope, $compile) {
// Consider using FosJsRouting bundle, if you want to use a Symfony2 route
$scope.formUrl = "http://url-to-fetch-my-form";
// Data from the form will be binded here
$scope.data = {};
// Method called when submitting the form
$scope.submit = function() {
@aronkerr
aronkerr / gist:6196208
Last active December 20, 2015 21:18
Get individual form elements from ZF2 collection
<?php
// Itterate over the collection and grap the elements
foreach($form->get('collectionName')->getIterator() as $fieldset)
{
echo $this->formRow($fieldset->get('elementName'));
echo $this->formRow($fieldset->get('elementAnotherElementName'));
@Ocramius
Ocramius / application.config.php
Created July 26, 2013 14:39
Disabling BjyAuthorize when in console environment in a Zend Framework 2 Application
<?php
use Zend\Console\Console;
$config = array(
'modules' => array(
'Application',
'DoctrineModule',
'DoctrineORMModule',
// ...
@joergbasedow
joergbasedow / SonataAdmin Filter Entities by NULL Fields
Last active August 5, 2018 03:28
I'm trying to filter entities by wether a fields value is NULL/NOT NULL/BOTH in SonataAdminBundle. Is there a more concise way?
<?php
// ...
class ProductAdmin extends SonataAdmin
{
// ...
protected function configureDatagridFilters(DatagridMapper $filter)
{
@venblee
venblee / Select 2 Val or Text
Created June 21, 2013 18:01
Get Value or Text from Select2
var test = $('#test');
$(test).select2({
data:[
{id:0,text:"enhancement"},
{id:1,text:"bug"},
{id:2,text:"duplicate"},
{id:3,text:"invalid"},
{id:4,text:"wontfix"}
],
width: "300px"
class I18nGenerator < Rails::Generators::NamedBase
def create_files
I18n.available_locales.each do |locale|
create_locale_file( locale )
end
end
private
def namespaces