Skip to content

Instantly share code, notes, and snippets.

View pjedrzejewski's full-sized avatar

Paweł Jędrzejewski pjedrzejewski

View GitHub Profile
$form = $this->get('sylius.assortment.form.category');
$category = $this->get('sylius.assortment.manager')->createCategory();
$form->bind($this->get('request'), $category);
if ($form->isValid()) {
$this->get('sylius.assortment.manager')->addCategory($category);
return new RedirectResponse($this->get('router')->generate('homepage'));
}
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://www.symfony-project.org/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="sylius.assortment.form.category.class">Sylius\AssortmentBundle\Form\CategoryForm</parameter>
<parameter key="sylius.assortment.form.category.name">form.category</parameter>
/**
* Products.
*
* @OneToMany(targetEntity="Sylius\AssortmentBundle\Entity\Product", mappedBy="category")
*/
protected $products;
/* ... */
public function __construct()
@pjedrzejewski
pjedrzejewski / gist:1217751
Created September 14, 2011 20:50
Test gist.
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@pjedrzejewski
pjedrzejewski / gist:1223256
Created September 16, 2011 21:51
Overriding templates in Symfony2, gist #1.
<?php
// ...
return $this->container->get('templating')->renderResponse('FOSUserBundle:Registration:register.html.'.$this->getEngine(), array(
'form' => $form->createView(),
'theme' => $this->container->getParameter('fos_user.template.theme'),
));
@pjedrzejewski
pjedrzejewski / gist:1223280
Created September 16, 2011 22:08
Overriding templates in Symfony2, gist #2.
<?php
// src/Application/Bundle/UserBundle.
namespace Application\Bundle\UserBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class ApplicationUserBundle extends Bundle
{
public function getParent()
{
@pjedrzejewski
pjedrzejewski / gist:1225175
Created September 18, 2011 15:40
Symfony2 configuration processor, gist #1.
# Super cool theme by super cool theme designer.
# (c) Super cool theme designer
theme:
name: "Super cool theme."
version: 0.1.2
description: |
The coolest theme evar.
@pjedrzejewski
pjedrzejewski / gist:1225191
Created September 18, 2011 15:49
Symfony2 configuration processor, gist #2.
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@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();
@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: