Skip to content

Instantly share code, notes, and snippets.

View pjedrzejewski's full-sized avatar

Paweł Jędrzejewski pjedrzejewski

View GitHub Profile
UserBundle_users_list:
   pattern:  /users/{page}.{_format}
   defaults: { _controller: UserBundle:Users:list, page: 1, _format: html }
   requirements:
      _format:  html
<?php
if (
!$this->isOauthExists()
&& ('oauth' === $driver
|| (isset($fetcherConfig['options']['method']) && 'oauth' === $fetcherConfig['options']['method']))
) {
throw new \InvalidArgumentException('You should install and enable InoriTwitterBundle');
}
@pjedrzejewski
pjedrzejewski / gist:2049871
Created March 16, 2012 12:30
Purge before scenario.
<?php
/**
* @BeforeScenario
*/
public function purgeDatabase()
{
$em = $this->getEntityManager();
$purger = new ORMPurger($em);
@pjedrzejewski
pjedrzejewski / gist:1241008
Created September 25, 2011 19:24
Easy categorizing with Symfony2, gist #6.
<?php
namespace Application\Bundle\AssortmentBundle\Form\Type;
use Sylius\Bundle\AssortmentBundle\Form\Type\ProductFormType as BaseProductFormType;
use Symfony\Component\Form\FormBuilder;
class ProductFormType extends BaseProductFormType
{
public function buildForm(FormBuilder $builder, array $options)
@pjedrzejewski
pjedrzejewski / gist:1240967
Created September 25, 2011 19:00
Easy categorizing with Symfony2, gist #5.
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Bundle\AssortmentBundle\Entity\Product" table="sylius_assortment_product">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
@pjedrzejewski
pjedrzejewski / gist:1240962
Created September 25, 2011 18:57
Easy categorizing with Symfony2, gist #4.
<?php
namespace Application\Bundle\AssortmentBundle\Entity;
use Sylius\Bundle\CatalogBundle\Model\CategoryInterface;
use Sylius\Bundle\AssortmentBundle\Entity\Product as BaseProduct;
class Product extends BaseProduct
{
protected $category;
@pjedrzejewski
pjedrzejewski / gist:1240959
Created September 25, 2011 18:53
Easy categorizing with Symfony2, gist #3.
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Bundle\AssortmentBundle\Entity\Category" table="sylius_assortment_category">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
@pjedrzejewski
pjedrzejewski / gist:1240954
Created September 25, 2011 18:46
Easy categorizing with Symfony2, gist #2.
<?php
namespace Application\Bundle\AssortmentBundle\Entity;
use Sylius\Bundle\CatalogBundle\Entity\Category as BaseCategory;
class Category extends BaseCategory
{
protected $products;
@pjedrzejewski
pjedrzejewski / gist:1240948
Created September 25, 2011 18:39
Easy categorizing with Symfony2, gist #1.
sylius_catalog:
driver: ORM
catalogs:
assortment:
mode: S # 'S' mode matches many products to one category, 'M' many products to many categories.
property: "products" # It is 'items' by default. Name of the category items property, used in mapping and templates.
classes:
model: Application\Bundle\AssortmentBundle\Entity\Category # Category entity.
templates: # Theese are optional as there are default templates.
backend:
@pjedrzejewski
pjedrzejewski / gist:1225223
Created September 18, 2011 16:11
Symfony2 configuration processor, gist #3.
<?php
namespace Sylius\Bundle\ThemingBundle\Packager;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Yaml\Yaml;
// ...
$processor = new Processor();