diff --git a/app/AppKernel.php b/app/AppKernel.php index 243b420..21fa915 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -23,6 +23,7 @@ public function registerBundles() new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(), new Hautelook\TemplatedUriBundle\HautelookTemplatedUriBundle(), new Bazinga\Bundle\RestExtraBundle\BazingaRestExtraBundle(), + new Codag\RestFabricationBundle\CodagRestFabricationBundle() ); if (in_array($this->getEnvironment(), array('dev', 'test'))) { diff --git a/composer.json b/composer.json index b3fc542..500f279 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "friendsofsymfony/http-cache-bundle": "~1.0", "willdurand/hateoas-bundle": "1.0.*@dev", "hautelook/templated-uri-bundle": "~2.0", - "willdurand/rest-extra-bundle": "~1.0" + "willdurand/rest-extra-bundle": "~1.0", + "codag/restfabrication-bundle": "dev-master" }, "conflict": { "symfony/routing": "2.4.1" diff --git a/composer.lock b/composer.lock index 19ee193..3aa00b9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,56 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "d78e39644d190c85680372c43debded4", + "hash": "dd8172c90fad23891ad11f411723bdc5", "packages": [ + { + "name": "codag/restfabrication-bundle", + "version": "dev-master", + "target-dir": "Codag/RestFabricationBundle", + "source": { + "type": "git", + "url": "https://github.com/Codag/RestFabricationBundle.git", + "reference": "45b2c23f4989d1c5a70430117da6eabde3370eb8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codag/RestFabricationBundle/zipball/45b2c23f4989d1c5a70430117da6eabde3370eb8", + "reference": "45b2c23f4989d1c5a70430117da6eabde3370eb8", + "shasum": "" + }, + "require": { + "doctrine/orm": "~2.2,>=2.2.3", + "friendsofsymfony/rest-bundle": "1.4.*", + "php": ">=5.3.2", + "symfony/form": "~2.2" + }, + "type": "symfony-bundle", + "autoload": { + "psr-0": { + "Codag\\RestFabricationBundle": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Codag", + "email": "mj@codag.ch", + "homepage": "http://codag.ch" + } + ], + "description": "Symfony2 Bundle for RAD of RESTful APIs on top of FOSRestBundle", + "homepage": "http://codag.ch", + "keywords": [ + "Symfony2", + "codag", + "fosrestbundle", + "rest" + ], + "time": "2014-12-02 23:41:28" + }, { "name": "doctrine/annotations", "version": "v1.2.1", @@ -272,9 +320,9 @@ "email": "kontakt@beberlei.de" }, { - "name": "Johannes M. Schmitt", + "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", + "homepage": "https://github.com/schmittjoh", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -291,16 +339,16 @@ }, { "name": "doctrine/dbal", - "version": "v2.4.2", + "version": "v2.4.3", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "fec965d330c958e175c39e61c3f6751955af32d0" + "reference": "0368bc031976126e5d36d37d2c56155092b6575b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/fec965d330c958e175c39e61c3f6751955af32d0", - "reference": "fec965d330c958e175c39e61c3f6751955af32d0", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/0368bc031976126e5d36d37d2c56155092b6575b", + "reference": "0368bc031976126e5d36d37d2c56155092b6575b", "shasum": "" }, "require": { @@ -312,7 +360,7 @@ "symfony/console": "~2.0" }, "suggest": { - "symfony/console": "Allows use of the command line interface" + "symfony/console": "For helpful console commands such as SQL execution and import of files." }, "type": "library", "autoload": { @@ -325,17 +373,6 @@ "MIT" ], "authors": [ - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/", - "role": "Creator" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": "http://www.instaclick.com" - }, { "name": "Roman Borschel", "email": "roman@code-factory.org" @@ -343,6 +380,14 @@ { "name": "Benjamin Eberlei", "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" } ], "description": "Database Abstraction Layer", @@ -353,7 +398,7 @@ "persistence", "queryobject" ], - "time": "2014-01-01 16:43:57" + "time": "2014-10-16 11:56:49" }, { "name": "doctrine/doctrine-bundle", @@ -362,25 +407,25 @@ "source": { "type": "git", "url": "https://github.com/doctrine/DoctrineBundle.git", - "reference": "v1.2.0" + "reference": "765b0d87fcc3e839c74817b7211258cbef3a4fb9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/v1.2.0", - "reference": "v1.2.0", + "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/765b0d87fcc3e839c74817b7211258cbef3a4fb9", + "reference": "765b0d87fcc3e839c74817b7211258cbef3a4fb9", "shasum": "" }, "require": { "doctrine/dbal": ">=2.2,<2.5-dev", - "jdorn/sql-formatter": ">=1.1,<2.0", + "jdorn/sql-formatter": "~1.1", "php": ">=5.3.2", - "symfony/doctrine-bridge": ">=2.2,<3.0", - "symfony/framework-bundle": ">=2.2,<3.0" + "symfony/doctrine-bridge": "~2.2", + "symfony/framework-bundle": "~2.2" }, "require-dev": { "doctrine/orm": ">=2.2,<2.5-dev", - "symfony/validator": ">=2.2,<3.0", - "symfony/yaml": ">=2.2,<3.0" + "symfony/validator": "~2.2", + "symfony/yaml": "~2.2" }, "suggest": { "doctrine/orm": "The Doctrine ORM integration is optional in the bundle.", @@ -404,7 +449,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -431,12 +478,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "v1.0" + "reference": "54b8333d2a5682afdc690060c1cf384ba9f47f08" }, "dist": { "type": "zip", - "url": "https://github.com/doctrine/inflector/archive/v1.0.zip", - "reference": "v1.0", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/54b8333d2a5682afdc690060c1cf384ba9f47f08", + "reference": "54b8333d2a5682afdc690060c1cf384ba9f47f08", "shasum": "" }, "require": { @@ -456,7 +503,8 @@ { "name": "Jonathan Wage", "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/" + "homepage": "http://www.jwage.com/", + "role": "Creator" }, { "name": "Guilherme Blanco", @@ -474,7 +522,7 @@ { "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", + "homepage": "https://github.com/schmittjoh", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -494,12 +542,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "v1.0" + "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb" }, "dist": { "type": "zip", - "url": "https://github.com/doctrine/lexer/archive/v1.0.zip", - "reference": "v1.0", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/2f708a85bb3aab5d99dab8be435abd73e0b18acb", + "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb", "shasum": "" }, "require": { @@ -526,9 +574,9 @@ "email": "roman@code-factory.org" }, { - "name": "Johannes M. Schmitt", + "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", + "homepage": "https://github.com/schmittjoh", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -542,16 +590,16 @@ }, { "name": "doctrine/orm", - "version": "v2.4.5", + "version": "v2.4.6", "source": { "type": "git", "url": "https://github.com/doctrine/doctrine2.git", - "reference": "c0d3cdbdfbf873871167050ab077e49b1ad02ab0" + "reference": "bebacf79d8d4dae9168f0f9bc6811e6c2cb6a4d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/c0d3cdbdfbf873871167050ab077e49b1ad02ab0", - "reference": "c0d3cdbdfbf873871167050ab077e49b1ad02ab0", + "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/bebacf79d8d4dae9168f0f9bc6811e6c2cb6a4d9", + "reference": "bebacf79d8d4dae9168f0f9bc6811e6c2cb6a4d9", "shasum": "" }, "require": { @@ -611,20 +659,20 @@ "database", "orm" ], - "time": "2014-09-22 21:58:51" + "time": "2014-10-06 13:22:50" }, { "name": "friendsofsymfony/http-cache", - "version": "1.0.0", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/FriendsOfSymfony/FOSHttpCache.git", - "reference": "8a842604322e728b629193739d388d0666a3c3f4" + "reference": "4e227b47754e2505fc6cf21cd2c4e98d625a3e11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfSymfony/FOSHttpCache/zipball/8a842604322e728b629193739d388d0666a3c3f4", - "reference": "8a842604322e728b629193739d388d0666a3c3f4", + "url": "https://api.github.com/repos/FriendsOfSymfony/FOSHttpCache/zipball/4e227b47754e2505fc6cf21cd2c4e98d625a3e11", + "reference": "4e227b47754e2505fc6cf21cd2c4e98d625a3e11", "shasum": "" }, "require": { @@ -644,7 +692,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -682,20 +730,20 @@ "purge", "varnish" ], - "time": "2014-08-14 11:08:09" + "time": "2014-11-21 13:36:18" }, { "name": "friendsofsymfony/http-cache-bundle", - "version": "1.0.1", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/FriendsOfSymfony/FOSHttpCacheBundle.git", - "reference": "e21bd9138631a03b34c9583aa730893c5c7290de" + "reference": "59e1b5034f0ef2afc9ffb2f39ee45b1b63d22f51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfSymfony/FOSHttpCacheBundle/zipball/e21bd9138631a03b34c9583aa730893c5c7290de", - "reference": "e21bd9138631a03b34c9583aa730893c5c7290de", + "url": "https://api.github.com/repos/FriendsOfSymfony/FOSHttpCacheBundle/zipball/59e1b5034f0ef2afc9ffb2f39ee45b1b63d22f51", + "reference": "59e1b5034f0ef2afc9ffb2f39ee45b1b63d22f51", "shasum": "" }, "require": { @@ -719,6 +767,11 @@ "symfony/expression-language": "For Tagged Cache Invalidation" }, "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, "autoload": { "psr-4": { "FOS\\HttpCacheBundle\\": "" @@ -753,7 +806,7 @@ "purge", "varnish" ], - "time": "2014-08-19 12:04:24" + "time": "2014-11-28 14:49:58" }, { "name": "friendsofsymfony/rest-bundle", @@ -1252,13 +1305,13 @@ "version": "1.0.0", "source": { "type": "git", - "url": "git://github.com/schmittjoh/parser-lib", - "reference": "1.0.0" + "url": "https://github.com/schmittjoh/parser-lib.git", + "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d" }, "dist": { "type": "zip", - "url": "https://github.com/schmittjoh/parser-lib/archive/1.0.0.zip", - "reference": "1.0.0", + "url": "https://api.github.com/repos/schmittjoh/parser-lib/zipball/c509473bc1b4866415627af0e1c6cc8ac97fa51d", + "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d", "shasum": "" }, "require": { @@ -1335,9 +1388,9 @@ ], "authors": [ { - "name": "Johannes M. Schmitt", + "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", + "homepage": "https://github.com/schmittjoh", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -1723,9 +1776,9 @@ ], "authors": [ { - "name": "Johannes M. Schmitt", + "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", + "homepage": "https://github.com/schmittjoh", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -1773,9 +1826,9 @@ ], "authors": [ { - "name": "Johannes M. Schmitt", + "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", + "homepage": "https://github.com/schmittjoh", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -1793,13 +1846,13 @@ "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/php-fig/log", - "reference": "1.0.0" + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" }, "dist": { "type": "zip", - "url": "https://github.com/php-fig/log/archive/1.0.0.zip", - "reference": "1.0.0", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", "shasum": "" }, "type": "library", @@ -1909,7 +1962,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" } ], "description": "This bundle provides a way to configure your controllers with annotations", @@ -2023,21 +2078,21 @@ }, { "name": "symfony/assetic-bundle", - "version": "v2.3.0", + "version": "v2.3.1", "target-dir": "Symfony/Bundle/AsseticBundle", "source": { "type": "git", "url": "https://github.com/symfony/AsseticBundle.git", - "reference": "146dd3cb46b302bd471560471c6aaa930483dac1" + "reference": "099e0bb5d80e7039af20db384a41017fde521f21" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/AsseticBundle/zipball/146dd3cb46b302bd471560471c6aaa930483dac1", - "reference": "146dd3cb46b302bd471560471c6aaa930483dac1", + "url": "https://api.github.com/repos/symfony/AsseticBundle/zipball/099e0bb5d80e7039af20db384a41017fde521f21", + "reference": "099e0bb5d80e7039af20db384a41017fde521f21", "shasum": "" }, "require": { - "kriswallsmith/assetic": "~1.1", + "kriswallsmith/assetic": "1.1.x", "php": ">=5.3.0", "symfony/framework-bundle": "~2.1" }, @@ -2056,7 +2111,7 @@ "type": "symfony-bundle", "extra": { "branch-alias": { - "dev-master": "2.1.x-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -2082,7 +2137,7 @@ "compression", "minification" ], - "time": "2013-05-16 05:32:23" + "time": "2013-11-25 16:34:50" }, { "name": "symfony/icu", @@ -2192,17 +2247,16 @@ }, { "name": "symfony/swiftmailer-bundle", - "version": "v2.3.7", - "target-dir": "Symfony/Bundle/SwiftmailerBundle", + "version": "v2.3.8", "source": { "type": "git", "url": "https://github.com/symfony/SwiftmailerBundle.git", - "reference": "e98defd402f72e8b54a029ba4d3ac4cb51dc3577" + "reference": "970b13d01871207e81d17b17ddda025e7e21e797" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/SwiftmailerBundle/zipball/e98defd402f72e8b54a029ba4d3ac4cb51dc3577", - "reference": "e98defd402f72e8b54a029ba4d3ac4cb51dc3577", + "url": "https://api.github.com/repos/symfony/SwiftmailerBundle/zipball/970b13d01871207e81d17b17ddda025e7e21e797", + "reference": "970b13d01871207e81d17b17ddda025e7e21e797", "shasum": "" }, "require": { @@ -2216,6 +2270,9 @@ "symfony/http-kernel": "~2.1", "symfony/yaml": "~2.1" }, + "suggest": { + "psr/log": "Allows logging" + }, "type": "symfony-bundle", "extra": { "branch-alias": { @@ -2223,8 +2280,8 @@ } }, "autoload": { - "psr-0": { - "Symfony\\Bundle\\SwiftmailerBundle": "" + "psr-4": { + "Symfony\\Bundle\\SwiftmailerBundle\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -2232,40 +2289,37 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony SwiftmailerBundle", "homepage": "http://symfony.com", - "time": "2014-04-05 17:15:52" + "time": "2014-12-01 17:44:50" }, { "name": "symfony/symfony", - "version": "v2.5.5", + "version": "v2.6.0", "source": { "type": "git", "url": "https://github.com/symfony/symfony.git", - "reference": "2aef97bbc95d0c4ae63537cca81bd6d984427d81" + "reference": "645bb3248db50d653d18929eb0c92b131b4f35ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/symfony/zipball/2aef97bbc95d0c4ae63537cca81bd6d984427d81", - "reference": "2aef97bbc95d0c4ae63537cca81bd6d984427d81", + "url": "https://api.github.com/repos/symfony/symfony/zipball/645bb3248db50d653d18929eb0c92b131b4f35ad", + "reference": "645bb3248db50d653d18929eb0c92b131b4f35ad", "shasum": "" }, "require": { "doctrine/common": "~2.2", "php": ">=5.3.3", "psr/log": "~1.0", - "symfony/icu": "~1.0", "twig/twig": "~1.12" }, "replace": { @@ -2275,6 +2329,7 @@ "symfony/console": "self.version", "symfony/css-selector": "self.version", "symfony/debug": "self.version", + "symfony/debug-bundle": "self.version", "symfony/dependency-injection": "self.version", "symfony/doctrine-bridge": "self.version", "symfony/dom-crawler": "self.version", @@ -2309,23 +2364,25 @@ "symfony/twig-bridge": "self.version", "symfony/twig-bundle": "self.version", "symfony/validator": "self.version", + "symfony/var-dumper": "self.version", "symfony/web-profiler-bundle": "self.version", "symfony/yaml": "self.version" }, "require-dev": { "doctrine/data-fixtures": "1.0.*", "doctrine/dbal": "~2.2", + "doctrine/doctrine-bundle": "~1.2", "doctrine/orm": "~2.2,>=2.2.3", "egulias/email-validator": "~1.2", "ircmaxell/password-compat": "1.0.*", - "monolog/monolog": "~1.3", + "monolog/monolog": "~1.11", "ocramius/proxy-manager": ">=0.3.1,<0.6-dev", - "propel/propel1": "1.6.*" + "propel/propel1": "~1.6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -2359,19 +2416,19 @@ "keywords": [ "framework" ], - "time": "2014-09-28 17:33:53" + "time": "2014-11-28 15:59:01" }, { "name": "twig/extensions", "version": "v1.0.1", "source": { "type": "git", - "url": "https://github.com/fabpot/Twig-extensions.git", + "url": "https://github.com/twigphp/Twig-extensions.git", "reference": "f91a82ec225e5bb108e01a0f93c9be04f84dcfa0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig-extensions/zipball/f91a82ec225e5bb108e01a0f93c9be04f84dcfa0", + "url": "https://api.github.com/repos/twigphp/Twig-extensions/zipball/f91a82ec225e5bb108e01a0f93c9be04f84dcfa0", "reference": "f91a82ec225e5bb108e01a0f93c9be04f84dcfa0", "shasum": "" }, @@ -2410,16 +2467,16 @@ }, { "name": "twig/twig", - "version": "v1.16.0", + "version": "v1.16.2", "source": { "type": "git", - "url": "https://github.com/fabpot/Twig.git", - "reference": "8ce37115802e257a984a82d38254884085060024" + "url": "https://github.com/twigphp/Twig.git", + "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/8ce37115802e257a984a82d38254884085060024", - "reference": "8ce37115802e257a984a82d38254884085060024", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/42f758d9fe2146d1f0470604fc05ee43580873fc", + "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc", "shasum": "" }, "require": { @@ -2463,7 +2520,7 @@ "keywords": [ "templating" ], - "time": "2014-07-05 12:19:05" + "time": "2014-10-17 12:53:44" }, { "name": "willdurand/hateoas", @@ -2537,12 +2594,12 @@ "source": { "type": "git", "url": "https://github.com/willdurand/BazingaHateoasBundle.git", - "reference": "ee7ce16ca2e7459577b5f85b035f5c9975a085e4" + "reference": "a83b4b02210050490aeece91905c8bf6398b0c86" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/willdurand/BazingaHateoasBundle/zipball/ee7ce16ca2e7459577b5f85b035f5c9975a085e4", - "reference": "ee7ce16ca2e7459577b5f85b035f5c9975a085e4", + "url": "https://api.github.com/repos/willdurand/BazingaHateoasBundle/zipball/a83b4b02210050490aeece91905c8bf6398b0c86", + "reference": "a83b4b02210050490aeece91905c8bf6398b0c86", "shasum": "" }, "require": { @@ -2572,8 +2629,7 @@ "authors": [ { "name": "William Durand", - "email": "william.durand1@gmail.com", - "homepage": "http://www.willdurand.fr" + "email": "william.durand1@gmail.com" } ], "description": "Integration of Hateoas into Symfony2.", @@ -2581,7 +2637,7 @@ "HATEOAS", "rest" ], - "time": "2014-07-17 09:43:35" + "time": "2014-10-26 23:43:33" }, { "name": "willdurand/jsonp-callback-validator", @@ -2725,22 +2781,17 @@ "time": "2014-08-23 16:56:20" } ], - "packages-dev": [ - - ], - "aliases": [ - - ], + "packages-dev": [], + "aliases": [], "minimum-stability": "stable", "stability-flags": { "jms/serializer-bundle": 20, - "willdurand/hateoas-bundle": 20 + "willdurand/hateoas-bundle": 20, + "codag/restfabrication-bundle": 20 }, "prefer-stable": false, "platform": { "php": ">=5.3.3" }, - "platform-dev": [ - - ] + "platform-dev": [] } diff --git a/src/Acme/DemoBundle/Controller/NoteController.php b/src/Acme/DemoBundle/Controller/NoteController.php index 1b663e8..cd01338 100644 --- a/src/Acme/DemoBundle/Controller/NoteController.php +++ b/src/Acme/DemoBundle/Controller/NoteController.php @@ -6,6 +6,7 @@ use Acme\DemoBundle\Model\Note; use Acme\DemoBundle\Model\NoteCollection; +use Codag\RestFabricationBundle\Exception\InvalidFormException; use FOS\RestBundle\Util\Codes; use FOS\RestBundle\Controller\Annotations; @@ -18,7 +19,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Form\FormTypeInterface; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Codag\RestFabricationBundle\Exception\ResourceNotFoundException; /** * Rest controller for notes @@ -36,6 +37,14 @@ public function getNoteManager() return $this->get('acme.demo.note_manager'); } + /** + * return \Codag\RestFabricationBundle\Form\Handler\CreateFormHandler + */ + public function getFormHandler() + { + return $this->get('acme.demo.form_handler.note'); + } + /** * List all notes. * @@ -85,13 +94,13 @@ public function getNotesAction(Request $request, ParamFetcherInterface $paramFet * * @return array * - * @throws NotFoundHttpException when note not exist + * @throws ResourceNotFoundException when note not exist */ public function getNoteAction(Request $request, $id) { $note = $this->getNoteManager()->get($id); if (false === $note) { - throw $this->createNotFoundException("Note does not exist."); + throw new ResourceNotFoundException("Note", $id); } $view = new View($note); @@ -140,22 +149,20 @@ public function newNoteAction() * @param Request $request the request object * * @return FormTypeInterface|RouteRedirectView + * + * @throws InvalidFormException when FormHandler receives invalid form */ public function postNotesAction(Request $request) { - $note = new Note(); - $form = $this->createForm(new NoteType(), $note); - - $form->submit($request); - if ($form->isValid()) { - $this->getNoteManager()->set($note); - - return $this->routeRedirectView('get_note', array('id' => $note->id)); + try { + $form = $this->createForm(new NoteType(), new Note()); + $new = $this->getFormHandler()->handle($form, $request); + return $this->routeRedirectView('get_note', array('id' => $new->id)); + }catch (InvalidFormException $exception) { + return array( + 'form' => $exception->getForm() + ); } - - return array( - 'form' => $form - ); } /** @@ -176,13 +183,13 @@ public function postNotesAction(Request $request) * * @return FormTypeInterface * - * @throws NotFoundHttpException when note not exist + * @throws ResourceNotFoundException when note not exist */ public function editNotesAction(Request $request, $id) { $note = $this->getNoteManager()->get($id); if (false === $note) { - throw $this->createNotFoundException("Note does not exist."); + throw new ResourceNotFoundException("Note", $id); } $form = $this->createForm(new NoteType(), $note); @@ -198,8 +205,7 @@ public function editNotesAction(Request $request, $id) * input = "Acme\DemoBundle\Form\NoteType", * statusCodes = { * 201 = "Returned when a new resource is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" + * 204 = "Returned when successful" * } * ) * @@ -213,29 +219,25 @@ public function editNotesAction(Request $request, $id) * * @return FormTypeInterface|RouteRedirectView * - * @throws NotFoundHttpException when note not exist + * @throws ResourceNotFoundException when note not exist */ public function putNotesAction(Request $request, $id) { - $note = $this->getNoteManager()->get($id); - if (false === $note) { - $note = new Note(); - $note->id = $id; - $statusCode = Codes::HTTP_CREATED; - } else { - $statusCode = Codes::HTTP_NO_CONTENT; - } - - $form = $this->createForm(new NoteType(), $note); + try { + if (!($object = $this->getNoteManager()->get($id))) { + $statusCode = Codes::HTTP_CREATED; + $form = $this->createForm(new NoteType(), new Note(), array('method' => 'POST')); + } else { + $statusCode = Codes::HTTP_NO_CONTENT; + $form = $this->createForm(new NoteType(), $object, array('method' => 'PUT')); + } + $object = $this->getFormHandler()->handle($form, $request); - $form->submit($request); - if ($form->isValid()) { - $this->getNoteManager()->set($note); + return $this->routeRedirectView('get_note', array('id' => $object->id), $statusCode); - return $this->routeRedirectView('get_note', array('id' => $note->id), $statusCode); + } catch (InvalidFormException $exception) { + return $exception->getForm(); } - - return $form; } /** @@ -244,7 +246,8 @@ public function putNotesAction(Request $request, $id) * @ApiDoc( * resource = true, * statusCodes={ - * 204="Returned when successful" + * 204="Returned when successful", + * 404 = "Returned when the note is not found" * } * ) * diff --git a/src/Acme/DemoBundle/NoteManager.php b/src/Acme/DemoBundle/NoteManager.php index fa756ff..8fb7e17 100644 --- a/src/Acme/DemoBundle/NoteManager.php +++ b/src/Acme/DemoBundle/NoteManager.php @@ -2,9 +2,10 @@ namespace Acme\DemoBundle; +use Codag\RestFabricationBundle\DomainManager\DomainManagerInterface; use Symfony\Component\Security\Core\Util\SecureRandomInterface; -class NoteManager +class NoteManager implements DomainManagerInterface { /** @var array notes */ protected $data = array(); @@ -79,4 +80,8 @@ public function remove($id) return true; } + + public function create($note){ + $this->set($note); + } } diff --git a/src/Acme/DemoBundle/Resources/config/services.xml b/src/Acme/DemoBundle/Resources/config/services.xml index cbde60b..1541fd7 100644 --- a/src/Acme/DemoBundle/Resources/config/services.xml +++ b/src/Acme/DemoBundle/Resources/config/services.xml @@ -9,6 +9,11 @@ %kernel.cache_dir% + + + + + diff --git a/src/Acme/DemoBundle/Tests/Controller/NoteControllerTest.php b/src/Acme/DemoBundle/Tests/Controller/NoteControllerTest.php index 3bcab0b..2094646 100644 --- a/src/Acme/DemoBundle/Tests/Controller/NoteControllerTest.php +++ b/src/Acme/DemoBundle/Tests/Controller/NoteControllerTest.php @@ -51,7 +51,7 @@ public function testGetNote() $response = $client->getResponse(); $this->assertEquals(404, $response->getStatusCode(), $response->getContent()); - $this->assertEquals('{"code":404,"message":"Note does not exist."}', $response->getContent()); + $this->assertEquals('{"code":404,"message":"Note not found with identifier: 0"}', $response->getContent()); $this->createNote($client, 'my note for get'); @@ -78,7 +78,7 @@ public function testGetNoteVersioned() $response = $client->getResponse(); $this->assertEquals(404, $response->getStatusCode(), $response->getContent()); - $this->assertEquals('{"code":404,"message":"Note does not exist."}', $response->getContent()); + $this->assertEquals('{"code":404,"message":"Note not found with identifier: 0"}', $response->getContent()); $this->createNote($client, 'my note for get'); @@ -128,7 +128,7 @@ public function testEditNote() $response = $client->getResponse(); $this->assertEquals(404, $response->getStatusCode(), $response->getContent()); - $this->assertEquals('{"code":404,"message":"Note does not exist."}', $response->getContent()); + $this->assertEquals('{"code":404,"message":"Note not found with identifier: 0"}', $response->getContent()); $this->createNote($client, 'my note for post');