Skip to content

Instantly share code, notes, and snippets.

View pjedrzejewski's full-sized avatar

Paweł Jędrzejewski pjedrzejewski

View GitHub Profile
@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: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: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: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: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.
*/
/**
* Products.
*
* @OneToMany(targetEntity="Sylius\AssortmentBundle\Entity\Product", mappedBy="category")
*/
protected $products;
/* ... */
public function __construct()
<?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>
$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'));
}