Made document editing possible

master
Polonkai Gergely 11 years ago
parent 1b55b079f4
commit b82b4ffd34

@ -6,13 +6,17 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use KekRozsak\FrontBundle\Entity\Document;
use KekRozsak\FrontBundle\Form\Type\DocumentType;
use KekRozsak\FrontBundle\Extensions\Slugifier;
class DocumentController extends Controller
{
/**
* @Route("/dokumentum/{documentSlug}", name="KekRozsakFrontBundle_documentView")
* @Template()
*/
public function documentViewAction($documentSlug)
public function viewAction($documentSlug)
{
$docRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Document');
if (!($document = $docRepo->findOneBySlug($documentSlug)))
@ -22,4 +26,86 @@ class DocumentController extends Controller
'document' => $document,
);
}
/**
* @Route("/dokumentumok/uj/{groupSlug}", name="KekRozsakFrontBundle_documentCreate", defaults={"groupslug"=""})
* @Template()
*/
public function createAction($groupSlug = '')
{
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Group');
$group = $groupRepo->findOneBySlug($groupSlug);
/* TODO: make group fully optional */
$document = new Document();
$document->setSlug('n-a');
$form = $this->createForm(new DocumentType(), $document);
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bindRequest($request);
if ($form->isValid())
{
$slugifier = new Slugifier();
$document->setSlug($slugifier->slugify($document->getTitle()));
$document->setCreatedAt(new \DateTime('now'));
$document->setCreatedBy($this->get('security.context')->getToken()->getUser());
if ($group)
{
$group->addDocument($document);
$document->addGroup($group);
}
$em = $this->getDoctrine()->getEntityManager();
$em->persist($document);
$em->flush();
/* TODO: return to group list if groupSlug is empty! */
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_groupDocuments', array('groupSlug' => $group->getSlug())));
}
}
return array(
'defaultGroup' => $groupSlug,
'form' => $form->createView(),
);
}
/**
* @Route("/dokumentum/{documentSlug}/szerkesztes", name="KekRozsakFrontBundle_documentEdit")
* @Template()
*/
public function editAction($documentSlug)
{
$documentRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Document');
if (!($document = $documentRepo->findOneBySlug($documentSlug)))
throw $this->createNotFoundException('A kért dokumentum nem létezik!');
$form = $this->createForm(new DocumentType(), $document);
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bindRequest($request);
if ($form->isValid())
{
$slugifier = new Slugifier();
$document->setSlug($slugifier->slugify($document->getTitle()));
// TODO: add updatedAt, updatedBy, updateReason, etc.
$em = $this->getDoctrine()->getEntityManager();
$em->persist($document);
$em->flush();
return $this->redirect($this->generateUrl('KekRozsakFrontBundle_documentView', array('documentSlug' => $document->getSlug())));
}
}
return array(
'document' => $document,
'form' => $form->createView(),
);
}
}

@ -4,6 +4,8 @@ namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
use KekRozsak\SecurityBundle\Entity\User;
use KekRozsak\FrontBundle\Entity\Group;
@ -12,6 +14,8 @@ use KekRozsak\FrontBundle\Entity\Group;
* KekRozsak\FrontBundle\Entity\Document
* @ORM\Entity
* @ORM\Table(name="documents")
* @DoctrineAssert\UniqueEntity(fields={"title"}, message="Ilyen című dokumentum már létezik. Kérlek válassz másikat!")
* @DoctrineAssert\UniqueEntity(fields={"slug"}, message="Ilyen című dokumentum már létezik. Kérlek válassz másikat!")
*/
class Document
{
@ -41,6 +45,7 @@ class Document
/**
* @var string $title
* @ORM\Column(type="string", length=150, unique=true, nullable=false)
* @Assert\NotBlank()
*/
protected $title;
@ -69,6 +74,7 @@ class Document
/**
* @var string $slug
* @ORM\Column(type="string", length=150, unique=true, nullable=false)
* @Assert\NotBlank()
*/
protected $slug;
@ -207,4 +213,88 @@ class Document
{
return $this->group;
}
/**
* @var KekRozsak\SecurityBundle\Entity\User $updatedBy
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
*/
protected $updatedBy;
/**
* Set updatedBy
*
* @param KekRozsak\SecurityBundle\Entity\User $updatedBy
* @return Document
*/
public function setUpdatedBy(\KekRozsak\SecurityBundle\Entity\User $updatedBy = null)
{
$this->updatedBy = $updatedBy;
return $this;
}
/**
* Get updatedBy
*
* @return KekRozsak\SecurityBundle\Entity\User
*/
public function getUpdatedBy()
{
return $this->updatedBy;
}
/**
* @var DateTime $updatedAt
* @ORM\Column(type="datetime", nullable=true)
*/
protected $updatedAt;
/**
* Set updatedAt
*
* @param DateTime $updatedAt
* @return Document
*/
public function setUpdatedAt(\DateTime $updatedAt = null)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* @var string updateReason
* @ORM\Column(type="text", nullable=true)
*/
protected $updateReason;
/**
* Set updateReason
*
* @param string $updateReason
* @return Document
*/
public function setUpdateReason($updateReason = null)
{
$this->updateReason = $updateReason;
return $this;
}
/**
* Get updateReason
*
* @return string
*/
public function getUpdateReason()
{
return $this->updateReason;
}
}

@ -0,0 +1,27 @@
<?php
namespace KekRozsak\FrontBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class DocumentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('title', null, array(
'label' => 'A dokumentum címe',
));
$builder->add('content', 'ckeditor', array(
'label' => ' ',
));
/* TODO: possibility to add to other groups! */
}
public function getName()
{
return 'document';
}
}

@ -0,0 +1,9 @@
{% extends '::main_template.html.twig' %}
{% block title %} - Dokumentum létrehozása{% endblock %}
{% block content %}
<h3>Új dokumentum létrehozása</h3>
<form method="post" action="{{ path('KekRozsakFrontBundle_documentCreate', { groupSlug: defaultGroup }) }}">
{{ form_widget(form) }}
<button type="submit">Mentés</button>
</form>
{% endblock content %}

@ -1,7 +0,0 @@
{% extends '::main_template.html.twig' %}
{% block title %} - Dokumentum - {{ document.title }}{% endblock %}
{% block content %}
<h3>{{ document.title }}</h3>
{{ document.content }}
<div class="szerzo">{{ document.createdBy.displayName }}</div>
{% endblock content %}

@ -0,0 +1,9 @@
{% extends '::main_template.html.twig' %}
{% block title %} - Dokumentum szerkesztése - {{ document.title }}{% endblock %}
{% block content %}
<h3>Dokumentum szerkesztése - {{ document.title }}</h3>
<form method="post" action="{{ path('KekRozsakFrontBundle_documentEdit', { documentSlug: document.slug }) }}">
{{ form_widget(form) }}
<button type="submit">Mentés</button>
</form>
{% endblock content %}

@ -0,0 +1,9 @@
{% extends '::main_template.html.twig' %}
{% block title %} - Dokumentum - {{ document.title }}{% endblock %}
{% block content %}
<h3>
{{ document.title }}{% if document.createdBy == app.user %} [ <a href="{{ path('KekRozsakFrontBundle_documentEdit', { documentSlug: document.slug }) }}">Szerkesztés</a> ] {% endif %}
</h3>
{{ document.content|raw }}
<div class="szerzo">{{ document.createdBy.displayName }}</div>
{% endblock content %}

@ -9,9 +9,25 @@
<li><a href="{{ path('KekRozsakFrontBundle_groupMembers', { groupSlug: group.slug }) }}">Tagok</a></li>
</ul>
<h3>{{ group.name }} - Dokumentumok</h3>
<ul>
<table>
<thead>
<tr>
<td colspan="2">Cím</td>
<td>Készítette</td>
</tr>
</thead>
<tbody>
{% for document in group.documents %}
<li><a href="{{ path('KekRozsakFrontBundle_documentView', { documentSlug: document.slug }) }}">{{ document.title }}</a></li>
<tr>
<td>[ikon]</td>
<td><a href="{{ path('KekRozsakFrontBundle_documentView', { documentSlug: document.slug }) }}">{{ document.title }}</a></td>
<td>
{{ document.createdBy.displayName }}<br />
{{ document.createdAt|date('Y-m-d H:i') }}
</td>
</tr>
{% endfor %}
</ul>
</tbody>
</table>
<a href="{{ path('KekRozsakFrontBundle_documentCreate', { groupSlug: group.slug }) }}">Új dokumentum</a>
{% endblock %}

@ -3,7 +3,7 @@
"name": "jms/metadata",
"version": "1.1.1",
"version_normalized": "1.1.1.0",
"time": "2011-12-29 19:32:49",
"time": "2011-12-29 14:32:49",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/metadata",
@ -47,7 +47,7 @@
"name": "jms/cg",
"version": "1.0.0",
"version_normalized": "1.0.0.0",
"time": "2011-12-29 18:40:52",
"time": "2011-12-29 13:40:52",
"source": {
"type": "git",
"url": "git://github.com/schmittjoh/cg-library.git",
@ -89,7 +89,7 @@
"version": "1.0.0",
"version_normalized": "1.0.0.0",
"target-dir": "JMS/AopBundle",
"time": "2011-12-29 18:50:26",
"time": "2011-12-29 13:50:26",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/JMSAopBundle",
@ -133,7 +133,7 @@
"version": "1.1.0",
"version_normalized": "1.1.0.0",
"target-dir": "JMS/SecurityExtraBundle",
"time": "2011-12-29 22:38:12",
"time": "2011-12-29 17:38:12",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/JMSSecurityExtraBundle",
@ -178,7 +178,7 @@
"version": "1.0.1",
"version_normalized": "1.0.1.0",
"target-dir": "JMS/DiExtraBundle",
"time": "2012-02-24 14:01:54",
"time": "2012-02-24 09:01:54",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/JMSDiExtraBundle",
@ -221,7 +221,7 @@
"name": "doctrine/common",
"version": "2.2.2",
"version_normalized": "2.2.2.0",
"time": "2012-04-06 21:46:44",
"time": "2012-04-06 11:46:44",
"source": {
"type": "git",
"url": "https://github.com/doctrine/common",
@ -287,7 +287,7 @@
"name": "monolog/monolog",
"version": "1.1.0",
"version_normalized": "1.1.0.0",
"time": "2012-04-17 08:27:40",
"time": "2012-04-16 22:27:40",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
@ -337,7 +337,7 @@
"name": "twig/extensions",
"version": "dev-master",
"version_normalized": "9999999-dev",
"time": "2012-05-15 15:28:19",
"time": "2012-05-15 05:28:19",
"source": {
"type": "git",
"url": "https://github.com/fabpot/Twig-extensions",
@ -378,71 +378,12 @@
}
}
},
{
"name": "kriswallsmith/assetic",
"version": "dev-master",
"version_normalized": "9999999-dev",
"time": "2012-06-06 19:41:54",
"source": {
"type": "git",
"url": "http://github.com/kriswallsmith/assetic.git",
"reference": "d6f89a3170c5280ad554347dc113eb25fdf00ad7"
},
"dist": {
"type": "zip",
"url": "https://github.com/kriswallsmith/assetic/zipball/d6f89a3170c5280ad554347dc113eb25fdf00ad7",
"reference": "d6f89a3170c5280ad554347dc113eb25fdf00ad7",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/process": "2.1.*"
},
"require-dev": {
"twig/twig": ">=1.6.0,<2.0",
"leafo/lessphp": "*"
},
"suggest": {
"twig/twig": "Assetic provides the integration with the Twig templating engine",
"leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"installation-source": "source",
"license": [
"MIT"
],
"authors": [
{
"name": "Kris Wallsmith",
"email": "kris.wallsmith@gmail.com",
"homepage": "http://kriswallsmith.net/",
"role": null
}
],
"description": "Asset Management for PHP",
"homepage": "https://github.com/kriswallsmith/assetic",
"keywords": [
"assets",
"compression",
"minification"
],
"autoload": {
"psr-0": {
"Assetic": "src/"
}
}
},
{
"name": "doctrine/doctrine-bundle",
"version": "dev-master",
"version_normalized": "9999999-dev",
"target-dir": "Doctrine/Bundle/DoctrineBundle",
"time": "2012-07-02 04:42:17",
"time": "2012-07-01 18:42:17",
"source": {
"type": "git",
"url": "git://github.com/doctrine/DoctrineBundle.git",
@ -516,7 +457,7 @@
"name": "doctrine/orm",
"version": "2.2.x-dev",
"version_normalized": "2.2.9999999.9999999-dev",
"time": "2012-07-06 01:48:00",
"time": "2012-07-05 15:48:00",
"source": {
"type": "git",
"url": "git://github.com/doctrine/doctrine2.git",
@ -581,7 +522,7 @@
"name": "doctrine/dbal",
"version": "2.2.x-dev",
"version_normalized": "2.2.9999999.9999999-dev",
"time": "2012-07-07 12:30:35",
"time": "2012-07-07 02:30:35",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal",
@ -647,7 +588,7 @@
"version": "dev-master",
"version_normalized": "9999999-dev",
"target-dir": "Sensio/Bundle/GeneratorBundle",
"time": "2012-07-12 18:04:48",
"time": "2012-07-12 08:04:48",
"source": {
"type": "git",
"url": "https://github.com/sensio/SensioGeneratorBundle",
@ -695,68 +636,12 @@
}
}
},
{
"name": "symfony/assetic-bundle",
"version": "dev-master",
"version_normalized": "9999999-dev",
"target-dir": "Symfony/Bundle/AsseticBundle",
"time": "2012-07-12 00:51:17",
"source": {
"type": "git",
"url": "https://github.com/symfony/AsseticBundle",
"reference": "ed933dcfa45f00b6bc6d7727007403f3ff429e5a"
},
"dist": {
"type": "zip",
"url": "https://github.com/symfony/AsseticBundle/zipball/ed933dcfa45f00b6bc6d7727007403f3ff429e5a",
"reference": "ed933dcfa45f00b6bc6d7727007403f3ff429e5a",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/framework-bundle": "2.1.*",
"kriswallsmith/assetic": "1.1.*"
},
"suggest": {
"symfony/twig-bundle": "2.1.*"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
},
"installation-source": "source",
"license": [
"MIT"
],
"authors": [
{
"name": "Kris Wallsmith",
"email": "kris.wallsmith@gmail.com",
"homepage": "http://kriswallsmith.net/",
"role": null
}
],
"description": "Integrates Assetic into Symfony2",
"homepage": "https://github.com/symfony/AsseticBundle",
"keywords": [
"assets",
"compression",
"minification"
],
"autoload": {
"psr-0": {
"Symfony\\Bundle\\AsseticBundle": ""
}
}
},
{
"name": "symfony/monolog-bundle",
"version": "dev-master",
"version_normalized": "9999999-dev",
"target-dir": "Symfony/Bundle/MonologBundle",
"time": "2012-06-29 23:48:07",
"time": "2012-06-29 13:48:07",
"source": {
"type": "git",
"url": "https://github.com/symfony/MonologBundle",
@ -816,7 +701,7 @@
"version": "dev-master",
"version_normalized": "9999999-dev",
"target-dir": "Sensio/Bundle/FrameworkExtraBundle",
"time": "2012-07-11 17:13:52",
"time": "2012-07-11 07:13:52",
"source": {
"type": "git",
"url": "https://github.com/sensio/SensioFrameworkExtraBundle",
@ -862,19 +747,19 @@
}
},
{
"name": "twig/twig",
"name": "swiftmailer/swiftmailer",
"version": "dev-master",
"version_normalized": "9999999-dev",
"time": "2012-07-15 17:42:44",
"time": "2012-07-12 20:47:17",
"source": {
"type": "git",
"url": "git://github.com/fabpot/Twig.git",
"reference": "d45664045194ef62573c153c424508527105041e"
"url": "git://github.com/swiftmailer/swiftmailer.git",
"reference": "8b2aa953f87da228ba413e8fb1372e49c1374050"
},
"dist": {
"type": "zip",
"url": "https://github.com/fabpot/Twig/zipball/d45664045194ef62573c153c424508527105041e",
"reference": "d45664045194ef62573c153c424508527105041e",
"url": "https://github.com/swiftmailer/swiftmailer/zipball/8b2aa953f87da228ba413e8fb1372e49c1374050",
"reference": "8b2aa953f87da228ba413e8fb1372e49c1374050",
"shasum": ""
},
"require": {
@ -883,12 +768,12 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
"dev-master": "4.2-dev"
}
},
"installation-source": "source",
"license": [
"BSD-3"
"LGPL"
],
"authors": [
{
@ -898,20 +783,65 @@
"role": null
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com",
"name": "Chris Corbyn",
"email": "",
"homepage": null,
"role": null
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "http://twig.sensiolabs.org",
"description": "Swiftmailer, free feature-rich PHP mailer",
"homepage": "http://swiftmailer.org",
"keywords": [
"templating"
"mail",
"mailer"
],
"autoload": {
"files": [
"lib/swift_required.php"
]
}
},
{
"name": "sensio/distribution-bundle",
"version": "dev-master",
"version_normalized": "9999999-dev",
"target-dir": "Sensio/Bundle/DistributionBundle",
"time": "2012-07-14 18:24:10",
"source": {
"type": "git",
"url": "https://github.com/sensio/SensioDistributionBundle",
"reference": "5886adae1613c0a72fbb95259a83ae798e86c0d3"
},
"dist": {
"type": "zip",
"url": "https://github.com/sensio/SensioDistributionBundle/zipball/5886adae1613c0a72fbb95259a83ae798e86c0d3",
"reference": "5886adae1613c0a72fbb95259a83ae798e86c0d3",
"shasum": ""
},
"require": {
"symfony/framework-bundle": "2.1.*"
},
"type": "symfony-bundle",
"installation-source": "source",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": null,
"role": null
}
],
"description": "The base bundle for the Symfony Distributions",
"keywords": [
"distribution",
"configuration"
],
"autoload": {
"psr-0": {
"Twig_": "lib/"
"Sensio\\Bundle\\DistributionBundle": ""
}
}
},
@ -920,16 +850,16 @@
"version": "dev-master",
"version_normalized": "9999999-dev",
"target-dir": "Symfony/Bundle/SwiftmailerBundle",
"time": "2012-07-05 05:33:34",
"time": "2012-07-19 01:55:12",
"source": {
"type": "git",
"url": "https://github.com/symfony/SwiftmailerBundle",
"reference": "v2.1.0-BETA3"
"reference": "65e6079443c3cd413012e146aa74307f18671f42"
},
"dist": {
"type": "zip",
"url": "https://github.com/symfony/SwiftmailerBundle/zipball/v2.1.0-BETA3",
"reference": "v2.1.0-BETA3",
"url": "https://github.com/symfony/SwiftmailerBundle/zipball/65e6079443c3cd413012e146aa74307f18671f42",
"reference": "65e6079443c3cd413012e146aa74307f18671f42",
"shasum": ""
},
"require": {
@ -975,145 +905,215 @@
}
},
{
"name": "swiftmailer/swiftmailer",
"name": "egeloen/ckeditor-bundle",
"version": "dev-master",
"version_normalized": "9999999-dev",
"time": "2012-07-13 06:47:17",
"target-dir": "Ivory/CKEditorBundle",
"time": "2012-05-28 11:16:47",
"source": {
"type": "git",
"url": "git://github.com/swiftmailer/swiftmailer.git",
"reference": "8b2aa953f87da228ba413e8fb1372e49c1374050"
"url": "https://github.com/egeloen/IvoryCKEditorBundle",
"reference": "98c9771b3d2748af0052b5efc697d5c1403c6473"
},
"dist": {
"type": "zip",
"url": "https://github.com/swiftmailer/swiftmailer/zipball/8b2aa953f87da228ba413e8fb1372e49c1374050",
"reference": "8b2aa953f87da228ba413e8fb1372e49c1374050",
"url": "https://github.com/egeloen/IvoryCKEditorBundle/zipball/98c9771b3d2748af0052b5efc697d5c1403c6473",
"reference": "98c9771b3d2748af0052b5efc697d5c1403c6473",
"shasum": ""
},
"require": {
"php": ">=5.2.4"
"php": ">=5.3.0",
"symfony/framework-bundle": "2.*"
},
"type": "symfony-bundle",
"installation-source": "source",
"license": [
"MIT"
],
"authors": [
{
"name": "Eric GELOEN",
"email": "geloen.eric@gmail.com",
"homepage": null,
"role": null
}
],
"description": "Provides a CKEditor integration for your Symfony2 Project.",
"keywords": [
"CKEditor"
],
"autoload": {
"psr-0": {
"Ivory\\CKEditorBundle": ""
}
}
},
{
"name": "kriswallsmith/assetic",
"version": "dev-master",
"version_normalized": "9999999-dev",
"time": "2012-07-20 10:33:33",
"source": {
"type": "git",
"url": "http://github.com/kriswallsmith/assetic.git",
"reference": "5c1c9b658b732a980312e8f29cec4e175c2bb6b2"
},
"dist": {
"type": "zip",
"url": "https://github.com/kriswallsmith/assetic/zipball/5c1c9b658b732a980312e8f29cec4e175c2bb6b2",
"reference": "5c1c9b658b732a980312e8f29cec4e175c2bb6b2",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/process": "2.1.*"
},
"require-dev": {
"twig/twig": ">=1.6.0,<2.0",
"leafo/lessphp": "*"
},
"suggest": {
"twig/twig": "Assetic provides the integration with the Twig templating engine",
"leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "1.1-dev"
}
},
"installation-source": "source",
"license": [
"LGPL"
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": null,
"role": null
},
{
"name": "Chris Corbyn",
"email": "",
"homepage": null,
"name": "Kris Wallsmith",
"email": "kris.wallsmith@gmail.com",
"homepage": "http://kriswallsmith.net/",
"role": null
}
],
"description": "Swiftmailer, free feature-rich PHP mailer",
"homepage": "http://swiftmailer.org",
"description": "Asset Management for PHP",
"homepage": "https://github.com/kriswallsmith/assetic",
"keywords": [
"mail",
"mailer"
"assets",
"compression",
"minification"
],
"autoload": {
"files": [
"lib/swift_required.php"
]
"psr-0": {
"Assetic": "src/"
}
}
},
{
"name": "sensio/distribution-bundle",
"name": "symfony/assetic-bundle",
"version": "dev-master",
"version_normalized": "9999999-dev",
"target-dir": "Sensio/Bundle/DistributionBundle",
"time": "2012-07-15 04:24:10",
"target-dir": "Symfony/Bundle/AsseticBundle",
"time": "2012-07-20 19:34:07",
"source": {
"type": "git",
"url": "https://github.com/sensio/SensioDistributionBundle",
"reference": "5886adae1613c0a72fbb95259a83ae798e86c0d3"
"url": "https://github.com/symfony/AsseticBundle",
"reference": "e5e9a56a872d9e1f305d14cd8296bf77888388af"
},
"dist": {
"type": "zip",
"url": "https://github.com/sensio/SensioDistributionBundle/zipball/5886adae1613c0a72fbb95259a83ae798e86c0d3",
"reference": "5886adae1613c0a72fbb95259a83ae798e86c0d3",
"url": "https://github.com/symfony/AsseticBundle/zipball/e5e9a56a872d9e1f305d14cd8296bf77888388af",
"reference": "e5e9a56a872d9e1f305d14cd8296bf77888388af",
"shasum": ""
},
"require": {
"symfony/framework-bundle": "2.1.*"
"php": ">=5.3.0",
"symfony/framework-bundle": "2.1.*",
"kriswallsmith/assetic": "1.1.*"
},
"suggest": {
"symfony/twig-bundle": "2.1.*"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
},
"installation-source": "source",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": null,
"name": "Kris Wallsmith",
"email": "kris.wallsmith@gmail.com",
"homepage": "http://kriswallsmith.net/",
"role": null
}
],
"description": "The base bundle for the Symfony Distributions",
"description": "Integrates Assetic into Symfony2",
"homepage": "https://github.com/symfony/AsseticBundle",
"keywords": [
"distribution",
"configuration"
"assets",
"compression",
"minification"
],
"autoload": {
"psr-0": {
"Sensio\\Bundle\\DistributionBundle": ""
"Symfony\\Bundle\\AsseticBundle": ""
}
}
},
{
"name": "egeloen/ckeditor-bundle",
"name": "twig/twig",
"version": "dev-master",
"version_normalized": "9999999-dev",
"target-dir": "Ivory/CKEditorBundle",
"time": "2012-05-28 13:16:47",
"time": "2012-07-20 12:41:38",
"source": {
"type": "git",
"url": "https://github.com/egeloen/IvoryCKEditorBundle",
"reference": "98c9771b3d2748af0052b5efc697d5c1403c6473"
"url": "git://github.com/fabpot/Twig.git",
"reference": "8a84838798e45424c5fe2d87149db6855ae037bf"
},
"dist": {
"type": "zip",
"url": "https://github.com/egeloen/IvoryCKEditorBundle/zipball/98c9771b3d2748af0052b5efc697d5c1403c6473",
"reference": "98c9771b3d2748af0052b5efc697d5c1403c6473",
"url": "https://github.com/fabpot/Twig/zipball/8a84838798e45424c5fe2d87149db6855ae037bf",
"reference": "8a84838798e45424c5fe2d87149db6855ae037bf",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/framework-bundle": "2.*"
"php": ">=5.2.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"type": "symfony-bundle",
"installation-source": "source",
"license": [
"MIT"
"BSD-3"
],
"authors": [
{
"name": "Eric GELOEN",
"email": "geloen.eric@gmail.com",
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": null,
"role": null
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com",
"homepage": null,
"role": null
}
],
"description": "Provides a CKEditor integration for your Symfony2 Project.",
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "http://twig.sensiolabs.org",
"keywords": [
"CKEditor"
"templating"
],
"autoload": {
"psr-0": {
"Ivory\\CKEditorBundle": ""
"Twig_": "lib/"
}
}
},
@ -1121,16 +1121,16 @@
"name": "symfony/symfony",
"version": "dev-master",
"version_normalized": "9999999-dev",
"time": "2012-07-17 09:07:53",
"time": "2012-07-21 11:16:18",
"source": {
"type": "git",
"url": "git://github.com/symfony/symfony.git",
"reference": "f52ce6178243e4b11aa09bde147f684d596fb120"
"reference": "6c256b01b087f94a4ec04487d875fe81375eb6c1"
},
"dist": {
"type": "zip",
"url": "https://github.com/symfony/symfony/zipball/f52ce6178243e4b11aa09bde147f684d596fb120",
"reference": "f52ce6178243e4b11aa09bde147f684d596fb120",
"url": "https://github.com/symfony/symfony/zipball/6c256b01b087f94a4ec04487d875fe81375eb6c1",
"reference": "6c256b01b087f94a4ec04487d875fe81375eb6c1",
"shasum": ""
},
"require": {

@ -0,0 +1,4 @@
phpunit.xml
vendor/
composer.phar
composer.lock

@ -1,5 +1,6 @@
{
"name": "kriswallsmith/assetic",
"minimum-stability": "dev",
"description": "Asset Management for PHP",
"keywords": ["assets", "compression", "minification"],
"homepage": "https://github.com/kriswallsmith/assetic",
@ -20,6 +21,7 @@
"twig/twig": ">=1.6.0,<2.0",
"leafo/lessphp": "*"
},
"minimum-stability": "dev",
"suggest": {
"twig/twig": "Assetic provides the integration with the Twig templating engine",
"leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler"

@ -25,6 +25,7 @@ use Symfony\Component\Process\ProcessBuilder;
class CompassFilter implements FilterInterface
{
private $compassPath;
private $rubyPath;
private $scss;
// sass options
@ -50,9 +51,10 @@ class CompassFilter implements FilterInterface
private $generatedImagesPath;
private $httpJavascriptsPath;
public function __construct($compassPath = '/usr/bin/compass')
public function __construct($compassPath = '/usr/bin/compass', $rubyPath = null)
{
$this->compassPath = $compassPath;
$this->rubyPath = $rubyPath;
$this->cacheLocation = sys_get_temp_dir();
if ('cli' !== php_sapi_name()) {
@ -133,6 +135,11 @@ class CompassFilter implements FilterInterface
$this->plugins[] = $plugin;
}
public function setLoadPaths(array $loadPaths)
{
$this->loadPaths = $loadPaths;
}
public function addLoadPath($loadPath)
{
$this->loadPaths[] = $loadPath;
@ -171,11 +178,16 @@ class CompassFilter implements FilterInterface
// compass does not seems to handle symlink, so we use realpath()
$tempDir = realpath(sys_get_temp_dir());
$pb = new ProcessBuilder(array(
$compassProcessArgs = array(
$this->compassPath,
'compile',
$tempDir,
));
);
if (null !== $this->rubyPath) {
array_unshift($compassProcessArgs, $this->rubyPath);
}
$pb = new ProcessBuilder($compassProcessArgs);
$pb->inheritEnvironmentVariables();
if ($this->force) {
@ -330,12 +342,12 @@ class CompassFilter implements FilterInterface
// does we have an associative array ?
if (count(array_filter(array_keys($array), "is_numeric")) != count($array)) {
foreach($array as $name => $value) {
foreach ($array as $name => $value) {
$output[] = sprintf(' :%s => "%s"', $name, addcslashes($value, '\\'));
}
$output = "{\n".implode(",\n", $output)."\n}";
} else {
foreach($array as $name => $value) {
foreach ($array as $name => $value) {
$output[] = sprintf(' "%s"', addcslashes($value, '\\'));
}
$output = "[\n".implode(",\n", $output)."\n]";

@ -30,6 +30,7 @@ class SassFilter implements FilterInterface
const STYLE_COMPRESSED = 'compressed';
private $sassPath;
private $rubyPath;
private $unixNewlines;
private $scss;
private $style;
@ -41,9 +42,10 @@ class SassFilter implements FilterInterface
private $noCache;
private $compass;
public function __construct($sassPath = '/usr/bin/sass')
public function __construct($sassPath = '/usr/bin/sass', $rubyPath = null)
{
$this->sassPath = $sassPath;
$this->rubyPath = $rubyPath;
$this->cacheLocation = realpath(sys_get_temp_dir());
}
@ -99,7 +101,12 @@ class SassFilter implements FilterInterface
public function filterLoad(AssetInterface $asset)
{
$pb = new ProcessBuilder(array($this->sassPath));
$sassProcessArgs = array($this->sassPath);
if (null !== $this->rubyPath) {
array_unshift($sassProcessArgs, $this->rubyPath);
}
$pb = new ProcessBuilder($sassProcessArgs);
$root = $asset->getSourceRoot();
$path = $asset->getSourcePath();

@ -19,9 +19,9 @@ namespace Assetic\Filter\Sass;
*/
class ScssFilter extends SassFilter
{
public function __construct($sassPath = '/usr/bin/sass')
public function __construct($sassPath = '/usr/bin/sass', $rubyPath = null)
{
parent::__construct($sassPath);
parent::__construct($sassPath, $rubyPath);
$this->setScss(true);
}

@ -80,11 +80,10 @@ abstract class BaseCompressorFilter implements FilterInterface
// input and output files
$tempDir = realpath(sys_get_temp_dir());
$hash = substr(sha1(time().rand(11111, 99999)), 0, 7);
$input = $tempDir.DIRECTORY_SEPARATOR.$hash.'.'.$type;
$output = $tempDir.DIRECTORY_SEPARATOR.$hash.'-min.'.$type;
$input = tempnam($tempDir, 'YUI-IN-');
$output = tempnam($tempDir, 'YUI-OUT-');
file_put_contents($input, $content);
$pb->add('-o')->add($output)->add($input);
$pb->add('-o')->add($output)->add('--type')->add($type)->add($input);
$proc = $pb->getProcess();
$code = $proc->run();

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
if (!$loader = @include __DIR__.'/../vendor/.composer/autoload.php') {
if (!$loader = @include __DIR__.'/../vendor/autoload.php') {
die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL);
@ -43,4 +43,4 @@ if (isset($_SERVER['PACKAGER'])) {
if (isset($_SERVER['PACKER'])) {
require_once $_SERVER['PACKER'];
}
}

@ -57,7 +57,7 @@ class DumpCommand extends ContainerAwareCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(sprintf('Dumping all <comment>%s</comment> assets.', $input->getOption('env')));
$output->writeln(sprintf('Debug mode is <comment>%s</comment>.', $input->getOption('no-debug') ? 'off' : 'on'));
$output->writeln(sprintf('Debug mode is <comment>%s</comment>.', $this->am->isDebug() ? 'on' : 'off'));
$output->writeln('');
if (!$input->getOption('watch')) {

@ -22,6 +22,7 @@
<service id="assetic.filter.compass" class="%assetic.filter.compass.class%">
<tag name="assetic.filter" alias="compass" />
<argument>%assetic.filter.compass.bin%</argument>
<argument>%assetic.ruby.bin%</argument>
<call method="setDebugInfo"><argument>%assetic.filter.compass.debug%</argument></call>
<call method="setStyle"><argument>%assetic.filter.compass.style%</argument></call>
<call method="setImagesDir"><argument>%assetic.filter.compass.images_dir%</argument></call>

@ -15,6 +15,7 @@
<service id="assetic.filter.sass" class="%assetic.filter.sass.class%">
<tag name="assetic.filter" alias="sass" />
<argument>%assetic.filter.sass.bin%</argument>
<argument>%assetic.ruby.bin%</argument>
<call method="setStyle"><argument>%assetic.filter.sass.style%</argument></call>
<call method="setCompass"><argument>%assetic.filter.sass.compass%</argument></call>
</service>

@ -15,6 +15,7 @@
<service id="assetic.filter.scss" class="%assetic.filter.scss.class%">
<tag name="assetic.filter" alias="scss" />
<argument>%assetic.filter.scss.sass%</argument>
<argument>%assetic.ruby.bin%</argument>
<call method="setStyle"><argument>%assetic.filter.scss.style%</argument></call>
<call method="setCompass"><argument>%assetic.filter.scss.compass%</argument></call>
</service>

@ -46,7 +46,13 @@
{% endfor %}
<p>
<pre>{{ message.body|e('html', message.charset)|convert_encoding('UTF-8', message.charset) }}</pre>
<pre>
{%- if message.charset %}
{{- message.body|e('html', message.charset)|convert_encoding('UTF-8', message.charset) }}
{%- else %}
{{- message.body|e('html') }}
{%- endif -%}
</pre>
</p>
{% endfor %}
{% endif %}

@ -13,14 +13,15 @@
configuration (i.e. `config.yml`), merging could yield a set of base URL's
for multiple environments.
* The priorities for the built-in listeners have changed:
2.0 2.1
security.firewall request 64 8
locale listener early_request 253 255
request -1 16
router listener early_request 255 128
request 10 32
* The priorities for the built-in listeners have changed.
```
2.0 2.1
security.firewall kernel.request 64 8
locale listener kernel.request 0 16
router listener early_request 255 n/a
request 0 32
```
### Doctrine
@ -106,7 +107,7 @@
if ($locale = $request->attributes->get('_locale')) {
$request->getSession()->set('_locale', $locale);
} else {
$request->setDefaultLocale($request->getSession()->get('_locale', $this->defaultLocale));
$request->setLocale($request->getSession()->get('_locale', $this->defaultLocale));
}
}
@ -1053,10 +1054,25 @@
$registry->addType($registry->resolveType(new MyFormType()));
```
* The method `renderBlock()` of the helper for the PHP Templating component was
deprecated and will be removed in Symfony 2.3. You should use `block()` instead.
Before:
```
<?php echo $view['form']->renderBlock('widget_attributes') ?>
```
After:
```
<?php echo $view['form']->block('widget_attributes') ?>
```
### Validator
* The methods `setMessage()`, `getMessageTemplate()` and
`getMessageParameters()` in the Constraint class were deprecated and will
`getMessageParameters()` in the `ConstraintValidator` class were deprecated and will
be removed in Symfony 2.3.
If you have implemented custom validators, you should use the

@ -9,3 +9,4 @@ CHANGELOG
* DoctrineOrmTypeGuesser now guesses "collection" for array Doctrine type
* DoctrineType now caches its choice lists in order to improve performance
* DoctrineType now uses ManagerRegistry::getManagerForClass() if the option "em" is not set
* UniqueEntity validation constraint now accepts a "repositoryMethod" option that will be used to check for uniqueness instead of the default "findBy"

@ -12,11 +12,12 @@
namespace Symfony\Bridge\Doctrine\Form;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\Mapping\MappingException;
use Doctrine\ORM\Mapping\MappingException as LegacyMappingException;
use Symfony\Component\Form\FormTypeGuesserInterface;
use Symfony\Component\Form\Guess\Guess;
use Symfony\Component\Form\Guess\TypeGuess;
use Symfony\Component\Form\Guess\ValueGuess;
use Doctrine\ORM\Mapping\MappingException;
class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
{
@ -145,6 +146,8 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
return $this->cache[$class] = array($em->getClassMetadata($class), $name);
} catch (MappingException $e) {
// not an entity or mapped super class
} catch (LegacyMappingException $e) {
// not an entity or mapped super class, using Doctrine ORM 2.2
}
}
}

@ -114,7 +114,7 @@ abstract class DoctrineType extends AbstractType
return $choiceListCache[$hash];
};
$emFilter = function (Options $options, $em) use ($registry) {
$emNormalizer = function (Options $options, $em) use ($registry) {
/* @var ManagerRegistry $registry */
if (null !== $em) {
return $registry->getManager($em);
@ -134,8 +134,8 @@ abstract class DoctrineType extends AbstractType
'group_by' => null,
));
$resolver->setFilters(array(
'em' => $emFilter,
$resolver->setNormalizers(array(
'em' => $emNormalizer,
));
}

@ -47,6 +47,50 @@ class UniqueValidatorTest extends DoctrineOrmTestCase
return $registry;
}
protected function createRepositoryMock()
{
$repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')
->setMethods(array('findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName'))
->getMock()
;
return $repository;
}
protected function createEntityManagerMock($repositoryMock)
{
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
->getMock()
;
$em->expects($this->any())
->method('getRepository')
->will($this->returnValue($repositoryMock))
;
$classMetadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$classMetadata
->expects($this->any())
->method('hasField')
->will($this->returnValue(true))
;
$refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty')
->disableOriginalConstructor()
->getMock()
;
$refl
->expects($this->any())
->method('getValue')
->will($this->returnValue(true))
;
$classMetadata->reflFields = array('name' => $refl);
$em->expects($this->any())
->method('getClassMetadata')
->will($this->returnValue($classMetadata))
;
return $em;
}
protected function createMetadataFactoryMock($metadata)
{
$metadataFactory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface');
@ -69,7 +113,7 @@ class UniqueValidatorTest extends DoctrineOrmTestCase
return $validatorFactory;
}
public function createValidator($entityManagerName, $em, $validateClass = null, $uniqueFields = null, $errorPath = null)
public function createValidator($entityManagerName, $em, $validateClass = null, $uniqueFields = null, $errorPath = null, $repositoryMethod = 'findBy')
{
if (!$validateClass) {
$validateClass = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIdentEntity';
@ -83,7 +127,13 @@ class UniqueValidatorTest extends DoctrineOrmTestCase
$uniqueValidator = new UniqueEntityValidator($registry);
$metadata = new ClassMetadata($validateClass);