Browse Source

update to Symfony 2.1

Bruno Galeotti 12 years ago
parent
commit
f62587831a

+ 1 - 0
.gitignore

@@ -9,3 +9,4 @@ vendor/
 /.settings
 /.buildpath
 /.project
+composer.phar

+ 8 - 7
README.md

@@ -6,13 +6,14 @@ Package Repository Website for Composer, see the [about page](http://packagist.o
 Installation
 ------------
 
-- Clone the repository
-- Run `bin/vendors install` to get all the vendors.
-- Copy `app/config/parameters.yml.dist` to `app/config/parameters.yml` and edit the relevant values for your setup.
-- Run `app/console doctrine:schema:create` to setup the DB.
-- Run `app/console assets:install web` to deploy the assets on the web dir.
-- Make a VirtualHost with DocumentRoot pointing to web/
-- You should now be able to access the site, create a user, etc.
+1. Clone the repository
+2. Install dependencies: `php composer.phar install`
+3. Copy `app/config/parameters.yml.dist` to `app/config/parameters.yml` and edit the relevant values for your setup.
+4. Run `app/console doctrine:schema:create` to setup the DB.
+5. Run `app/console assets:install web` to deploy the assets on the web dir.
+6. Make a VirtualHost with DocumentRoot pointing to web/
+
+You should now be able to access the site, create a user, etc.
 
 Setting up search
 -----------------

+ 4 - 1
app/AppKernel.php

@@ -16,9 +16,12 @@ class AppKernel extends Kernel
             new Symfony\Bundle\TwigBundle\TwigBundle(),
             new Symfony\Bundle\MonologBundle\MonologBundle(),
             new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
-            new Symfony\Bundle\DoctrineBundle\DoctrineBundle(),
             new Symfony\Bundle\AsseticBundle\AsseticBundle(),
+            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
             new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
+            new JMS\AopBundle\JMSAopBundle(),
+            new JMS\DiExtraBundle\JMSDiExtraBundle($this),
+            new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
             new FOS\UserBundle\FOSUserBundle(),
             new Snc\RedisBundle\SncRedisBundle(),
             new Packagist\WebBundle\PackagistWebBundle(),

+ 6 - 4
app/Resources/FOSUserBundle/views/layout.html.twig

@@ -2,10 +2,12 @@
 
 {% block content %}
 
-    {% for key, flash in app.session.getFlashes() %}
-	    <div class="{{ flash }}" style="margin-bottom: 5px;">
-	        {{ key|trans({}, 'FOSUserBundle') }}
-	    </div>
+    {% for type, flashMessages in app.session.flashbag.all() %}
+        {% for flashMessage in flashMessages %}
+            <div class="{{ type }}" style="margin-bottom: 5px;">
+                {{ flashMessage|trans({}, 'FOSUserBundle') }}
+            </div>
+        {% endfor %}
     {% endfor %}
 
     <div class="box clearfix">

+ 22 - 44
app/autoload.php

@@ -1,54 +1,32 @@
 <?php
 
-use Symfony\Component\ClassLoader\UniversalClassLoader;
 use Doctrine\Common\Annotations\AnnotationRegistry;
 
-$loader = new UniversalClassLoader();
-$loader->registerNamespaces(array(
-    'Symfony'          => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
-    'Sensio'           => __DIR__.'/../vendor/bundles',
-    'JMS'              => __DIR__.'/../vendor/bundles',
-    'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
-    'Doctrine\\DBAL'   => __DIR__.'/../vendor/doctrine-dbal/lib',
-    'Doctrine'         => __DIR__.'/../vendor/doctrine/lib',
-    'Monolog'          => __DIR__.'/../vendor/monolog/src',
-    'Assetic'          => __DIR__.'/../vendor/assetic/src',
-    'Metadata'         => __DIR__.'/../vendor/metadata/src',
-    'FOS'              => __DIR__.'/../vendor/bundles',
-    'Snc'              => __DIR__.'/../vendor/bundles',
-    'Predis'           => __DIR__.'/../vendor/predis/lib',
-    'Composer'         => __DIR__.'/../vendor/composer/src',
-    'Packagist'        => __DIR__.'/../src',
-    'WhiteOctober\PagerfantaBundle' => __DIR__.'/../vendor/bundles',
-    'Pagerfanta'  => __DIR__.'/../vendor/pagerfanta/src',
-    'Nelmio'           => __DIR__.'/../vendor/bundles',
-    'Seld\JsonLint'    => __DIR__.'/../vendor/jsonlint/src',
-));
-$loader->registerPrefixes(array(
-    'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',
-    'Twig_'            => __DIR__.'/../vendor/twig/lib',
-    'Solarium_'        => __DIR__.'/../vendor/solarium/library',
-));
+if (!$loader = @include __DIR__.'/../vendor/autoload.php') {
+
+    $message = <<< EOF
+<p>You must set up the project dependencies by running the following commands:</p>
+<pre>
+    curl -s http://getcomposer.org/installer | php
+    php composer.phar install
+</pre>
+
+EOF;
+
+    if (PHP_SAPI === 'cli') {
+        $message = strip_tags($message);
+    }
+
+    die($message);
+}
 
 // intl
 if (!function_exists('intl_get_error_code')) {
-    require_once __DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
+    require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
 
-    $loader->registerPrefixFallbacks(array(__DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs'));
+    $loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
 }
 
-$loader->registerNamespaceFallbacks(array(
-    __DIR__.'/../src',
-));
-$loader->register();
-
-AnnotationRegistry::registerLoader(function($class) use ($loader) {
-    $loader->loadClass($class);
-    return class_exists($class, false);
-});
-AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
-
-// Swiftmailer needs a special autoloader to allow
-// the lazy loading of the init file (which is expensive)
-require_once __DIR__.'/../vendor/swiftmailer/lib/classes/Swift.php';
-Swift::registerAutoload(__DIR__.'/../vendor/swiftmailer/lib/swift_init.php');
+AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
+
+return $loader;

+ 2 - 2
app/config/config.yml

@@ -11,11 +11,11 @@ framework:
     validation:      { enable_annotations: true }
     translator:      { fallback: en }
     templating:      { engines: ['twig'] } #assets_version: SomeVersionScheme
+    default_locale: %locale%
     session:
         name:           packagist
-        default_locale: %locale%
         lifetime:       3600
-        auto_start:     false
+        auto_start:     true
 
 # Twig Configuration
 twig:

+ 10 - 0
app/config/security.yml

@@ -1,4 +1,14 @@
+jms_security_extra:
+    secure_all_services: false
+    expressions: true
+
 security:
+    encoders:
+        FOS\UserBundle\Model\UserInterface:
+            algorithm:        sha512
+            encode_as_base64: false
+            iterations:       1
+
     providers:
         packagist:
             id: packagist.user_provider

+ 0 - 154
bin/vendors

@@ -1,154 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-/*
- * This file is part of the Symfony Standard Edition.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-set_time_limit(0);
-
-$rootDir = dirname(__DIR__);
-$vendorDir = $rootDir.'/vendor';
-
-array_shift($argv);
-if (!isset($argv[0])) {
-    exit(<<<EOF
-Symfony2 vendors script management.
-
-Specify a command to run:
-
- install: install vendors as specified in deps or deps.lock (recommended)
- update:  update vendors to their latest versions (as specified in deps)
- lock:  lock vendors to their current versions
-
-EOF
-    );
-}
-
-if (!in_array($command = array_shift($argv), array('install', 'update', 'lock'))) {
-    exit(sprintf('Command "%s" does not exist.', $command).PHP_EOL);
-}
-
-/*
- * Check wether this project is based on the Standard Edition that was
- * shipped with vendors or not.
- */
-if (is_dir($vendorDir.'/symfony') && !is_dir($vendorDir.'/symfony/.git') && !in_array('--reinstall', $argv)) {
-    exit(<<<EOF
-Your project seems to be based on a Standard Edition that includes vendors.
-
-Try to run ./bin/vendors install --reinstall
-
-
-EOF
-    );
-}
-
-if (!is_dir($vendorDir)) {
-    mkdir($vendorDir, 0777, true);
-}
-
-// versions
-$versions = array();
-if ('install' === $command && file_exists($rootDir.'/deps.lock')) {
-    foreach (file($rootDir.'/deps.lock', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
-        $parts = array_values(array_filter(explode(' ', $line)));
-        if (2 !== count($parts)) {
-            exit(sprintf('The deps version file is not valid (near "%s")', $line).PHP_EOL);
-        }
-        $versions[$parts[0]] = $parts[1];
-    }
-}
-
-$newversions = array();
-$deps = parse_ini_file($rootDir.'/deps', true, INI_SCANNER_RAW);
-if (false === $deps) {
-    exit('The deps file is not valid ini syntax. Perhaps missing a trailing newline?'.PHP_EOL);
-}
-foreach ($deps as $name => $dep) {
-    $dep = array_map('trim', $dep);
-
-    // install dir
-    $installDir = isset($dep['target']) ? $vendorDir.'/'.$dep['target'] : $vendorDir.'/'.$name;
-    if (in_array('--reinstall', $argv)) {
-        if (defined('PHP_WINDOWS_VERSION_BUILD')) {
-            system(sprintf('rmdir /S /Q %s', escapeshellarg(realpath($installDir))));
-        } else {
-            system(sprintf('rm -rf %s', escapeshellarg($installDir)));
-        }
-    }
-
-    if ('install' === $command || 'update' === $command) {
-        echo '> Installing/Updating '.$name.PHP_EOL;
-
-        // url
-        if (!isset($dep['git'])) {
-            exit(sprintf('The "git" value for the "%s" dependency must be set.', $name).PHP_EOL);
-        }
-        $url = $dep['git'];
-
-        if (!is_dir($installDir)) {
-            system(sprintf('git clone %s %s', escapeshellarg($url), escapeshellarg($installDir)));
-        }
-
-        // revision
-        if (isset($versions[$name])) {
-            $rev = $versions[$name];
-        } else {
-            $rev = isset($dep['version']) ? $dep['version'] : 'origin/HEAD';
-        }
-
-        $status = system(sprintf('cd %s && git status --porcelain', escapeshellarg($installDir)));
-        if (!empty($status)) {
-            exit(sprintf('"%s" has local modifications. Please revert or commit/push them before running this command again.', $name).PHP_EOL);
-        }
-        $current_rev = system(sprintf('cd %s && git rev-list --max-count=1 HEAD', escapeshellarg($installDir)));
-        if ($current_rev === $rev) {
-            continue;
-        }
-
-        system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
-    }
-
-    if ('update' === $command || 'lock' === $command) {
-        ob_start();
-        system(sprintf('cd %s && git log -n 1 --format=%%H', escapeshellarg($installDir)));
-        $newversion = trim(ob_get_clean());
-
-        ob_start();
-        system(sprintf('cd %s && git name-rev --tags --name-only %s', escapeshellarg($installDir), $newversion));
-        // remove trailing ^0 from tags, those are the tags themselves
-        $niceversion = preg_replace('/\^0$/', '', trim(ob_get_clean()));
-
-        // undefined is returned in case no name-rev could be found
-        if ('undefined' !== $niceversion) {
-            $newversions[] = $name.' '.$niceversion;
-        } else {
-            $newversions[] = $name.' '.$newversion;
-        }
-    }
-}
-
-// update?
-if ('update' === $command || 'lock' === $command) {
-    echo '> Updating deps.lock'.PHP_EOL;
-
-    file_put_contents($rootDir.'/deps.lock', implode("\n", $newversions)."\n");
-}
-
-// php on windows can't use the shebang line from system()
-$interpreter = defined('PHP_WINDOWS_VERSION_BUILD') ? 'php.exe' : '';
-
-// Update the bootstrap files
-system(sprintf('%s %s %s', $interpreter, escapeshellarg($rootDir.'/vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php'), escapeshellarg($rootDir)));
-
-// Update assets
-system(sprintf('%s %s assets:install %s', $interpreter, escapeshellarg($rootDir.'/app/console'), escapeshellarg($rootDir.'/web/')));
-
-// Remove the cache
-system(sprintf('%s %s cache:clear --no-warmup', $interpreter, escapeshellarg($rootDir.'/app/console')));

+ 66 - 0
composer.json

@@ -0,0 +1,66 @@
+{
+    "name": "composer/packagist",
+    "description": "Package Repository Website",
+    "keywords": ["package", "composer"],
+    "homepage": "http://packagist.org/",
+    "type": "library",
+    "license": "MIT",
+    "authors": [
+        {
+            "name": "Nils Adermann",
+            "email": "naderman@naderman.de",
+            "homepage": "http://www.naderman.de"
+        },
+        {
+            "name": "Jordi Boggiano",
+            "email": "j.boggiano@seld.be",
+            "homepage": "http://seld.be"
+        }
+    ],
+    "support": {
+          "email": "contact@packagist.org"
+    },
+    "autoload": {
+        "psr-0": { "Packagist": "src/" }
+    },
+    "require": {
+        "php": ">=5.3.2",
+        "composer/composer": "dev-master",
+        "doctrine/doctrine-bundle": "dev-master",
+        "doctrine/orm": "2.2.*",
+        "friendsofsymfony/user-bundle": "dev-master",
+        "jms/di-extra-bundle": "1.0.*",
+        "jms/security-extra-bundle": "1.1.*",
+        "nelmio/solarium-bundle": "dev-master",
+        "predis/predis": "0.7.*",
+        "sensio/distribution-bundle": "dev-master",
+        "sensio/framework-extra-bundle": "dev-master",
+        "sensio/generator-bundle": "dev-master",
+        "snc/redis-bundle": "dev-master",
+        "symfony/assetic-bundle": "dev-master",
+        "symfony/monolog-bundle": "dev-master",
+        "symfony/swiftmailer-bundle": "dev-master",
+        "symfony/symfony": "2.1.*",
+        "twig/extensions": "dev-master",
+        "white-october/pagerfanta-bundle": "dev-master"
+    },
+    "scripts": {
+        "post-install-cmd": [
+            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
+            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
+            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets"
+        ],
+        "post-update-cmd": [
+            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
+            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
+            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets"
+        ]
+    },
+    "config": {
+        "bin-dir": "bin"
+    },
+    "extra": {
+        "symfony-app-dir": "app",
+        "symfony-web-dir": "web"
+    }
+}

+ 0 - 96
deps

@@ -1,96 +0,0 @@
-[symfony]
-    git=http://github.com/symfony/symfony.git
-    version=v2.0.10
-
-[twig]
-    git=http://github.com/fabpot/Twig.git
-    version=v1.8.0
-
-[monolog]
-    git=http://github.com/Seldaek/monolog.git
-    version=1.0.2
-
-[doctrine-common]
-    git=http://github.com/doctrine/common.git
-    version=2.1.4
-
-[doctrine-dbal]
-    git=http://github.com/doctrine/dbal.git
-    version=2.1.6
-
-[doctrine]
-    git=http://github.com/doctrine/doctrine2.git
-    version=2.1.6
-
-[swiftmailer]
-    git=http://github.com/swiftmailer/swiftmailer.git
-    version=v4.1.5
-
-[assetic]
-    git=http://github.com/kriswallsmith/assetic.git
-    version=v1.0.2
-
-[twig-extensions]
-    git=http://github.com/fabpot/Twig-extensions.git
-
-[metadata]
-    git=http://github.com/schmittjoh/metadata.git
-    version=1.0.0
-
-[composer]
-    git=http://github.com/composer/composer.git
-    version=origin/master
-
-[SensioFrameworkExtraBundle]
-    git=http://github.com/sensio/SensioFrameworkExtraBundle.git
-    target=/bundles/Sensio/Bundle/FrameworkExtraBundle
-    version=origin/2.0
-
-[SensioDistributionBundle]
-    git=http://github.com/sensio/SensioDistributionBundle.git
-    target=/bundles/Sensio/Bundle/DistributionBundle
-    version=origin/2.0
-
-[SensioGeneratorBundle]
-    git=http://github.com/sensio/SensioGeneratorBundle.git
-    target=/bundles/Sensio/Bundle/GeneratorBundle
-    version=origin/2.0
-
-[AsseticBundle]
-    git=http://github.com/symfony/AsseticBundle.git
-    target=/bundles/Symfony/Bundle/AsseticBundle
-    version=v1.0.1
-
-[FOSUserBundle]
-    git=http://github.com/FriendsOfSymfony/FOSUserBundle.git
-    target=/bundles/FOS/UserBundle
-    version=1.1.0
-
-[WhiteOctoberPagerfanta]
-    git=http://github.com/whiteoctober/Pagerfanta.git
-    target=/pagerfanta
-
-[WhiteOctoberPagerfantaBundle]
-    git=http://github.com/whiteoctober/WhiteOctoberPagerfantaBundle.git
-    target=/bundles/WhiteOctober/PagerfantaBundle
-    version=origin/symfony2.0
-
-[solarium]
-    git=https://github.com/basdenooijer/solarium.git
-    version=2.3.0-RC1
-
-[NelmioSolariumBundle]
-    git=https://github.com/nelmio/NelmioSolariumBundle.git
-    target=/bundles/Nelmio/SolariumBundle
-
-[jsonlint]
-    git=https://github.com/Seldaek/jsonlint.git
-
-[SncRedisBundle]
-    git=http://github.com/snc/SncRedisBundle.git
-    target=/bundles/Snc/RedisBundle
-    version=origin/master
-
-[predis]
-    git=http://github.com/nrk/predis.git
-    version=origin/v0.7

+ 0 - 23
deps.lock

@@ -1,23 +0,0 @@
-symfony v2.0.10
-twig v1.6.0
-monolog 1.0.2
-doctrine-common 2.1.4
-doctrine-dbal 2.1.6
-doctrine 2.1.6
-swiftmailer v4.1.5
-assetic v1.0.2
-twig-extensions 4c831657215e51568fcb31bb9142e827f9a69bd5
-metadata 1.0.0
-composer a06ebdd8ef94c27dc5a96b4015211b4660d03a66
-SensioFrameworkExtraBundle 638f545b7020b9e9d5944a7e3167f60ed848250d
-SensioDistributionBundle 20b66a408084ad8752f98e50f10533f5245310bf
-SensioGeneratorBundle b1ccb78c1743f30817b0fce9bb5c6baff6ed7bf8
-AsseticBundle v1.0.1
-FOSUserBundle 1.1.0
-WhiteOctoberPagerfanta c490684def33e992241e7fad33bcbd03d9d18643
-WhiteOctoberPagerfantaBundle 40209ef994fa2f342660d96bf6bea3f88171cd2d
-solarium 2.3.0-RC1
-NelmioSolariumBundle 75c1c8481b3e6be50f1509ab8290181c48b1169e
-jsonlint 30acd3065fde017eece3fc292c623694b5ed8bf9
-SncRedisBundle 23c1814a179598d62f6c50290472234e8e4faedd
-predis f4c58b926b21c34f7d59dd5d40e91c51198712c5

+ 0 - 5
src/Packagist/WebBundle/Controller/WebController.php

@@ -42,11 +42,6 @@ use Pagerfanta\Adapter\SolariumAdapter;
  */
 class WebController extends Controller
 {
-    protected function getUser()
-    {
-        return $user = $this->get('security.context')->getToken()->getUser();
-    }
-
     /**
      * @Template()
      * @Route("/", name="home")

+ 7 - 11
src/Packagist/WebBundle/Entity/Package.php

@@ -142,15 +142,13 @@ class Package
 
     public function isRepositoryValid(ExecutionContext $context)
     {
-        $propertyPath = $context->getPropertyPath() . '.repository';
-        $context->setPropertyPath($propertyPath);
-
+        $property = 'repository';
         $repo = $this->repositoryClass;
         if (!$repo) {
             if (preg_match('{//.+@}', $this->repository)) {
-                $context->addViolation('URLs with user@host are not supported, use a read-only public URL', array(), null);
+                $context->addViolationAtSubPath($property, 'URLs with user@host are not supported, use a read-only public URL', array(), null);
             } else {
-                $context->addViolation('No valid/supported repository was found at the given URL', array(), null);
+                $context->addViolationAtSubPath($property, 'No valid/supported repository was found at the given URL', array(), null);
             }
             return;
         }
@@ -158,16 +156,16 @@ class Package
             $information = $repo->getComposerInformation($repo->getRootIdentifier());
 
             if (!isset($information['name']) || !$information['name']) {
-                $context->addViolation('The package name was not found in the composer.json, make sure there is a name present.', array(), null);
+                $context->addViolationAtSubPath($property, 'The package name was not found in the composer.json, make sure there is a name present.', array(), null);
                 return;
             }
 
             if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}i', $information['name'])) {
-                $context->addViolation('The package name '.$information['name'].' is invalid, it should have a vendor name, a forward slash, and a package name, matching <em>[a-z0-9_.-]+/[a-z0-9_.-]+</em>.', array(), null);
+                $context->addViolationAtSubPath($property, 'The package name '.$information['name'].' is invalid, it should have a vendor name, a forward slash, and a package name, matching <em>[a-z0-9_.-]+/[a-z0-9_.-]+</em>.', array(), null);
                 return;
             }
         } catch (\Exception $e) {
-            $context->addViolation('We had problems parsing your composer.json file, the parser reports: '.$e->getMessage(), array(), null);
+            $context->addViolationAtSubPath($property, 'We had problems parsing your composer.json file, the parser reports: '.$e->getMessage(), array(), null);
         }
     }
 
@@ -180,9 +178,7 @@ class Package
     {
         try {
             if ($this->entityRepository->findOneByName($this->name)) {
-                $propertyPath = $context->getPropertyPath() . '.repository';
-                $context->setPropertyPath($propertyPath);
-                $context->addViolation('A package with the name '.$this->name.' already exists.', array(), null);
+                $context->addViolationAtSubPath('repository', 'A package with the name '.$this->name.' already exists.', array(), null);
             }
         } catch (\Doctrine\ORM\NoResultException $e) {}
     }

+ 6 - 5
src/Packagist/WebBundle/Form/Type/AddMaintainerRequestType.php

@@ -13,23 +13,24 @@
 namespace Packagist\WebBundle\Form\Type;
 
 use Symfony\Component\Form\AbstractType;
-use Symfony\Component\Form\FormBuilder;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
 
 /**
  * @author Jordi Boggiano <j.boggiano@seld.be>
  */
 class AddMaintainerRequestType extends AbstractType
 {
-    public function buildForm(FormBuilder $builder, array $options)
+    public function buildForm(FormBuilderInterface $builder, array $options)
     {
         $builder->add('user', 'fos_user_username');
     }
 
-    public function getDefaultOptions(array $options)
+    public function setDefaultOptions(OptionsResolverInterface $resolver)
     {
-        return array(
+        $resolver->setDefaults(array(
             'data_class' => 'Packagist\WebBundle\Form\Model\AddMaintainerRequest',
-        );
+        ));
     }
 
     public function getName()

+ 6 - 5
src/Packagist/WebBundle/Form/Type/PackageType.php

@@ -13,23 +13,24 @@
 namespace Packagist\WebBundle\Form\Type;
 
 use Symfony\Component\Form\AbstractType;
-use Symfony\Component\Form\FormBuilder;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
 
 /**
  * @author Jordi Boggiano <j.boggiano@seld.be>
  */
 class PackageType extends AbstractType
 {
-    public function buildForm(FormBuilder $builder, array $options)
+    public function buildForm(FormBuilderInterface $builder, array $options)
     {
         $builder->add('repository');
     }
 
-    public function getDefaultOptions(array $options)
+    public function setDefaultOptions(OptionsResolverInterface $resolver)
     {
-        return array(
+        $resolver->setDefaults(array(
             'data_class' => 'Packagist\WebBundle\Entity\Package',
-        );
+        ));
     }
 
     public function getName()

+ 6 - 5
src/Packagist/WebBundle/Form/Type/SearchQueryType.php

@@ -13,24 +13,25 @@
 namespace Packagist\WebBundle\Form\Type;
 
 use Symfony\Component\Form\AbstractType;
-use Symfony\Component\Form\FormBuilder;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
 
 /**
  * @author Igor Wiedler <igor@wiedler.ch>
  */
 class SearchQueryType extends AbstractType
 {
-    public function buildForm(FormBuilder $builder, array $options)
+    public function buildForm(FormBuilderInterface $builder, array $options)
     {
         $builder->add('query', 'search');
     }
 
-    public function getDefaultOptions(array $options)
+    public function setDefaultOptions(OptionsResolverInterface $resolver)
     {
-        return array(
+        $resolver->setDefaults(array(
             'data_class' => 'Packagist\WebBundle\Form\Model\SearchQuery',
             'csrf_protection' => false,
-        );
+        ));
     }
 
     public function getName()

+ 6 - 7
src/Packagist/WebBundle/Resources/views/layout.html.twig

@@ -50,17 +50,16 @@
             </header>
 
             <div class="main" role="main">
-                {% if app.session.flash('success') %}
+                {% for flashMessage in app.session.flashbag.get('success') %}
                     <div class="flash-message success">
-                        <p>{{ app.session.flash('success') }}</p>
+                        <p>{{ flashMessage }}</p>
                     </div>
-                {% endif %}
-                {% if app.session.flash('error') %}
+                {% endfor %}
+                {% for flashMessage in app.session.flashbag.get('error') %}
                     <div class="flash-message error">
-                        <p>{{ app.session.flash('error') }}</p>
+                        <p>{{ flashMessage }}</p>
                     </div>
-                {% endif %}
-                {{ app.session.clearFlashes }}
+                {% endfor %}
 
                 {% block search %}
                     {% if searchForm is defined %}