Simplify controller boilerplate with a new trait

This commit is contained in:
Timothy Warren 2018-07-16 13:10:00 -04:00
parent b5f62d7e7e
commit 828e644fc1
26 changed files with 995 additions and 321 deletions

View File

@ -13,6 +13,7 @@
"symfony/framework-bundle": "^4.0", "symfony/framework-bundle": "^4.0",
"symfony/maker-bundle": "^1.0", "symfony/maker-bundle": "^1.0",
"symfony/monolog-bundle": "^3.1", "symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "^1.0",
"symfony/twig-bundle": "^4.0", "symfony/twig-bundle": "^4.0",
"symfony/yaml": "^4.0", "symfony/yaml": "^4.0",
"twig/twig": "^2.0 || ^3.0" "twig/twig": "^2.0 || ^3.0"

730
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "c30e49aedab6bfa3ef5026b7536c8e6c", "content-hash": "c45658330a726b8a2e60f60143bb93b0",
"packages": [ "packages": [
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
@ -217,33 +217,39 @@
}, },
{ {
"name": "doctrine/common", "name": "doctrine/common",
"version": "v2.8.1", "version": "v2.9.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/common.git", "url": "https://github.com/doctrine/common.git",
"reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66" "reference": "a210246d286c77d2b89040f8691ba7b3a713d2c1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/f68c297ce6455e8fd794aa8ffaf9fa458f6ade66", "url": "https://api.github.com/repos/doctrine/common/zipball/a210246d286c77d2b89040f8691ba7b3a713d2c1",
"reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66", "reference": "a210246d286c77d2b89040f8691ba7b3a713d2c1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/annotations": "1.*", "doctrine/annotations": "^1.0",
"doctrine/cache": "1.*", "doctrine/cache": "^1.0",
"doctrine/collections": "1.*", "doctrine/collections": "^1.0",
"doctrine/inflector": "1.*", "doctrine/event-manager": "^1.0",
"doctrine/lexer": "1.*", "doctrine/inflector": "^1.0",
"php": "~7.1" "doctrine/lexer": "^1.0",
"doctrine/persistence": "^1.0",
"doctrine/reflection": "^1.0",
"php": "^7.1"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^5.7" "doctrine/coding-standard": "^1.0",
"phpunit/phpunit": "^6.3",
"squizlabs/php_codesniffer": "^3.0",
"symfony/phpunit-bridge": "^4.0.5"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.8.x-dev" "dev-master": "2.9.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -275,10 +281,14 @@
{ {
"name": "Johannes Schmitt", "name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com" "email": "schmittjoh@gmail.com"
},
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com"
} }
], ],
"description": "Common Library for Doctrine projects", "description": "Common Library for Doctrine projects",
"homepage": "http://www.doctrine-project.org", "homepage": "https://www.doctrine-project.org",
"keywords": [ "keywords": [
"annotations", "annotations",
"collections", "collections",
@ -286,32 +296,35 @@
"persistence", "persistence",
"spl" "spl"
], ],
"time": "2017-08-31T08:43:38+00:00" "time": "2018-07-12T21:16:12+00:00"
}, },
{ {
"name": "doctrine/dbal", "name": "doctrine/dbal",
"version": "v2.7.1", "version": "v2.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/dbal.git", "url": "https://github.com/doctrine/dbal.git",
"reference": "11037b4352c008373561dc6fc836834eed80c3b5" "reference": "5140a64c08b4b607b9bedaae0cedd26f04a0e621"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/11037b4352c008373561dc6fc836834eed80c3b5", "url": "https://api.github.com/repos/doctrine/dbal/zipball/5140a64c08b4b607b9bedaae0cedd26f04a0e621",
"reference": "11037b4352c008373561dc6fc836834eed80c3b5", "reference": "5140a64c08b4b607b9bedaae0cedd26f04a0e621",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/common": "^2.7.1", "doctrine/cache": "^1.0",
"doctrine/event-manager": "^1.0",
"ext-pdo": "*", "ext-pdo": "*",
"php": "^7.1" "php": "^7.1"
}, },
"require-dev": { "require-dev": {
"doctrine/coding-standard": "^4.0", "doctrine/coding-standard": "^4.0",
"phpunit/phpunit": "^7.0", "jetbrains/phpstorm-stubs": "^2018.1.2",
"phpstan/phpstan": "^0.10.1",
"phpunit/phpunit": "^7.1.2",
"phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5", "phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5",
"symfony/console": "^2.0.5||^3.0", "symfony/console": "^2.0.5|^3.0|^4.0",
"symfony/phpunit-bridge": "^3.4.5|^4.0.5" "symfony/phpunit-bridge": "^3.4.5|^4.0.5"
}, },
"suggest": { "suggest": {
@ -323,7 +336,8 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.7.x-dev" "dev-master": "2.8.x-dev",
"dev-develop": "3.0.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -361,7 +375,7 @@
"persistence", "persistence",
"queryobject" "queryobject"
], ],
"time": "2018-04-07T18:44:18+00:00" "time": "2018-07-13T03:16:35+00:00"
}, },
{ {
"name": "doctrine/doctrine-bundle", "name": "doctrine/doctrine-bundle",
@ -536,6 +550,141 @@
], ],
"time": "2018-03-27T09:22:12+00:00" "time": "2018-03-27T09:22:12+00:00"
}, },
{
"name": "doctrine/doctrine-migrations-bundle",
"version": "v1.3.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/DoctrineMigrationsBundle.git",
"reference": "a9e506369f931351a2a6dd2aef588a822802b1b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/a9e506369f931351a2a6dd2aef588a822802b1b7",
"reference": "a9e506369f931351a2a6dd2aef588a822802b1b7",
"shasum": ""
},
"require": {
"doctrine/doctrine-bundle": "~1.0",
"doctrine/migrations": "^1.1",
"php": ">=5.4.0",
"symfony/framework-bundle": "~2.7|~3.3|~4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Bundle\\MigrationsBundle\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Doctrine Project",
"homepage": "http://www.doctrine-project.org"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "Symfony DoctrineMigrationsBundle",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"dbal",
"migrations",
"schema"
],
"time": "2017-11-01T09:13:26+00:00"
},
{
"name": "doctrine/event-manager",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/event-manager.git",
"reference": "a520bc093a0170feeb6b14e9d83f3a14452e64b3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/event-manager/zipball/a520bc093a0170feeb6b14e9d83f3a14452e64b3",
"reference": "a520bc093a0170feeb6b14e9d83f3a14452e64b3",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"conflict": {
"doctrine/common": "<2.9@dev"
},
"require-dev": {
"doctrine/coding-standard": "^4.0",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\": "lib/Doctrine/Common"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
},
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com"
}
],
"description": "Doctrine Event Manager component",
"homepage": "https://www.doctrine-project.org/projects/event-manager.html",
"keywords": [
"event",
"eventdispatcher",
"eventmanager"
],
"time": "2018-06-11T11:59:03+00:00"
},
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",
"version": "v1.3.0", "version": "v1.3.0",
@ -712,17 +861,91 @@
"time": "2014-09-09T13:34:57+00:00" "time": "2014-09-09T13:34:57+00:00"
}, },
{ {
"name": "doctrine/orm", "name": "doctrine/migrations",
"version": "v2.6.1", "version": "v1.8.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/doctrine2.git", "url": "https://github.com/doctrine/migrations.git",
"reference": "87ee409783a4a322b5597ebaae558661404055a7" "reference": "215438c0eef3e5f9b7da7d09c6b90756071b43e6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/doctrine2/zipball/87ee409783a4a322b5597ebaae558661404055a7", "url": "https://api.github.com/repos/doctrine/migrations/zipball/215438c0eef3e5f9b7da7d09c6b90756071b43e6",
"reference": "87ee409783a4a322b5597ebaae558661404055a7", "reference": "215438c0eef3e5f9b7da7d09c6b90756071b43e6",
"shasum": ""
},
"require": {
"doctrine/dbal": "~2.6",
"ocramius/proxy-manager": "^1.0|^2.0",
"php": "^7.1",
"symfony/console": "~3.3|^4.0"
},
"require-dev": {
"doctrine/coding-standard": "^1.0",
"doctrine/orm": "~2.5",
"jdorn/sql-formatter": "~1.1",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "~7.0",
"squizlabs/php_codesniffer": "^3.0",
"symfony/yaml": "~3.3|^4.0"
},
"suggest": {
"jdorn/sql-formatter": "Allows to generate formatted SQL with the diff command.",
"symfony/yaml": "Allows the use of yaml for migration configuration files."
},
"bin": [
"bin/doctrine-migrations"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "v1.8.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\DBAL\\Migrations\\": "lib/Doctrine/DBAL/Migrations",
"Doctrine\\Migrations\\": "lib/Doctrine/Migrations"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Michael Simonson",
"email": "contact@mikesimonson.com"
}
],
"description": "Database Schema migrations using Doctrine DBAL",
"homepage": "https://www.doctrine-project.org/projects/migrations.html",
"keywords": [
"database",
"migrations"
],
"time": "2018-06-06T21:00:30+00:00"
},
{
"name": "doctrine/orm",
"version": "v2.6.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/doctrine2.git",
"reference": "d2b4dd71d2a276edd65d0c170375b445f8a4a4a8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/doctrine2/zipball/d2b4dd71d2a276edd65d0c170375b445f8a4a4a8",
"reference": "d2b4dd71d2a276edd65d0c170375b445f8a4a4a8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -791,7 +1014,160 @@
"database", "database",
"orm" "orm"
], ],
"time": "2018-02-27T07:30:56+00:00" "time": "2018-07-12T20:47:13+00:00"
},
{
"name": "doctrine/persistence",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/persistence.git",
"reference": "17896f6d56a2794a1619e019596ae627aabd8fd5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/persistence/zipball/17896f6d56a2794a1619e019596ae627aabd8fd5",
"reference": "17896f6d56a2794a1619e019596ae627aabd8fd5",
"shasum": ""
},
"require": {
"doctrine/annotations": "^1.0",
"doctrine/cache": "^1.0",
"doctrine/collections": "^1.0",
"doctrine/event-manager": "^1.0",
"doctrine/reflection": "^1.0",
"php": "^7.1"
},
"conflict": {
"doctrine/common": "<2.9@dev"
},
"require-dev": {
"doctrine/coding-standard": "^4.0",
"phpstan/phpstan": "^0.8",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\": "lib/Doctrine/Common"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
},
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com"
}
],
"description": "Doctrine Persistence abstractions.",
"homepage": "https://doctrine-project.org/projects/persistence.html",
"keywords": [
"persistence"
],
"time": "2018-06-14T18:57:48+00:00"
},
{
"name": "doctrine/reflection",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/reflection.git",
"reference": "02538d3f95e88eb397a5f86274deb2c6175c2ab6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/reflection/zipball/02538d3f95e88eb397a5f86274deb2c6175c2ab6",
"reference": "02538d3f95e88eb397a5f86274deb2c6175c2ab6",
"shasum": ""
},
"require": {
"doctrine/annotations": "^1.0",
"ext-tokenizer": "*",
"php": "^7.1"
},
"require-dev": {
"doctrine/coding-standard": "^4.0",
"doctrine/common": "^2.8",
"phpstan/phpstan": "^0.9.2",
"phpstan/phpstan-phpunit": "^0.9.4",
"phpunit/phpunit": "^7.0",
"squizlabs/php_codesniffer": "^3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\": "lib/Doctrine/Common"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
},
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com"
}
],
"description": "Doctrine Reflection component",
"homepage": "https://www.doctrine-project.org/projects/reflection.html",
"keywords": [
"reflection"
],
"time": "2018-06-14T14:45:07+00:00"
}, },
{ {
"name": "easycorp/easy-log-handler", "name": "easycorp/easy-log-handler",
@ -973,16 +1349,16 @@
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v4.0.2", "version": "v4.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "35b8caf75e791ba1b2d24fec1552168d72692b12" "reference": "bd088dc940a418f09cda079a9b5c7c478890fb8d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/35b8caf75e791ba1b2d24fec1552168d72692b12", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bd088dc940a418f09cda079a9b5c7c478890fb8d",
"reference": "35b8caf75e791ba1b2d24fec1552168d72692b12", "reference": "bd088dc940a418f09cda079a9b5c7c478890fb8d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1020,7 +1396,126 @@
"parser", "parser",
"php" "php"
], ],
"time": "2018-06-03T11:33:10+00:00" "time": "2018-07-15T17:25:16+00:00"
},
{
"name": "ocramius/package-versions",
"version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/Ocramius/PackageVersions.git",
"reference": "4489d5002c49d55576fa0ba786f42dbb009be46f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/4489d5002c49d55576fa0ba786f42dbb009be46f",
"reference": "4489d5002c49d55576fa0ba786f42dbb009be46f",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0.0",
"php": "^7.1.0"
},
"require-dev": {
"composer/composer": "^1.6.3",
"ext-zip": "*",
"infection/infection": "^0.7.1",
"phpunit/phpunit": "^7.0.0"
},
"type": "composer-plugin",
"extra": {
"class": "PackageVersions\\Installer",
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"PackageVersions\\": "src/PackageVersions"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com"
}
],
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"time": "2018-02-05T13:05:30+00:00"
},
{
"name": "ocramius/proxy-manager",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/Ocramius/ProxyManager.git",
"reference": "81d53b2878f1d1c40ad27270e64b51798485dfc5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Ocramius/ProxyManager/zipball/81d53b2878f1d1c40ad27270e64b51798485dfc5",
"reference": "81d53b2878f1d1c40ad27270e64b51798485dfc5",
"shasum": ""
},
"require": {
"ocramius/package-versions": "^1.1.3",
"php": "^7.2.0",
"zendframework/zend-code": "^3.3.0"
},
"require-dev": {
"couscous/couscous": "^1.6.1",
"ext-phar": "*",
"humbug/humbug": "1.0.0-RC.0@RC",
"nikic/php-parser": "^3.1.1",
"padraic/phpunit-accelerator": "dev-master@DEV",
"phpbench/phpbench": "^0.12.2",
"phpstan/phpstan": "dev-master#856eb10a81c1d27c701a83f167dc870fd8f4236a as 0.9.999",
"phpstan/phpstan-phpunit": "dev-master#5629c0a1f4a9c417cb1077cf6693ad9753895761",
"phpunit/phpunit": "^6.4.3",
"squizlabs/php_codesniffer": "^2.9.1"
},
"suggest": {
"ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects",
"zendframework/zend-json": "To have the JsonRpc adapter (Remote Object feature)",
"zendframework/zend-soap": "To have the Soap adapter (Remote Object feature)",
"zendframework/zend-xmlrpc": "To have the XmlRpc adapter (Remote Object feature)"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-0": {
"ProxyManager\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "http://ocramius.github.io/"
}
],
"description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies",
"homepage": "https://github.com/Ocramius/ProxyManager",
"keywords": [
"aop",
"lazy loading",
"proxy",
"proxy pattern",
"service proxies"
],
"time": "2017-11-16T23:22:31+00:00"
}, },
{ {
"name": "psr/cache", "name": "psr/cache",
@ -2665,6 +3160,34 @@
], ],
"time": "2018-05-31T10:17:53+00:00" "time": "2018-05-31T10:17:53+00:00"
}, },
{
"name": "symfony/orm-pack",
"version": "v1.0.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/orm-pack.git",
"reference": "1b58f752cd917a08c9c8df020781d9c46a2275b1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/orm-pack/zipball/1b58f752cd917a08c9c8df020781d9c46a2275b1",
"reference": "1b58f752cd917a08c9c8df020781d9c46a2275b1",
"shasum": ""
},
"require": {
"doctrine/doctrine-bundle": "^1.6.10",
"doctrine/doctrine-migrations-bundle": "^1.3",
"doctrine/orm": "^2.5.11",
"php": "^7.0"
},
"type": "symfony-pack",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A pack for the Doctrine ORM",
"time": "2017-12-12T01:47:50+00:00"
},
{ {
"name": "symfony/polyfill-ctype", "name": "symfony/polyfill-ctype",
"version": "v1.8.0", "version": "v1.8.0",
@ -3479,20 +4002,21 @@
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v2.4.8", "version": "v2.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "7b604c89da162034bdf4bb66310f358d313dd16d" "reference": "6a5f676b77a90823c2d4eaf76137b771adf31323"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/7b604c89da162034bdf4bb66310f358d313dd16d", "url": "https://api.github.com/repos/twigphp/Twig/zipball/6a5f676b77a90823c2d4eaf76137b771adf31323",
"reference": "7b604c89da162034bdf4bb66310f358d313dd16d", "reference": "6a5f676b77a90823c2d4eaf76137b771adf31323",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.0", "php": "^7.0",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-mbstring": "~1.0" "symfony/polyfill-mbstring": "~1.0"
}, },
"require-dev": { "require-dev": {
@ -3503,7 +4027,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.4-dev" "dev-master": "2.5-dev"
} }
}, },
"autoload": { "autoload": {
@ -3532,16 +4056,123 @@
}, },
{ {
"name": "Twig Team", "name": "Twig Team",
"homepage": "http://twig.sensiolabs.org/contributors", "homepage": "https://twig.symfony.com/contributors",
"role": "Contributors" "role": "Contributors"
} }
], ],
"description": "Twig, the flexible, fast, and secure template language for PHP", "description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "http://twig.sensiolabs.org", "homepage": "https://twig.symfony.com",
"keywords": [ "keywords": [
"templating" "templating"
], ],
"time": "2018-04-02T09:24:19+00:00" "time": "2018-07-13T07:18:09+00:00"
},
{
"name": "zendframework/zend-code",
"version": "3.3.0",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-code.git",
"reference": "6b1059db5b368db769e4392c6cb6cc139e56640d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-code/zipball/6b1059db5b368db769e4392c6cb6cc139e56640d",
"reference": "6b1059db5b368db769e4392c6cb6cc139e56640d",
"shasum": ""
},
"require": {
"php": "^7.1",
"zendframework/zend-eventmanager": "^2.6 || ^3.0"
},
"require-dev": {
"doctrine/annotations": "~1.0",
"ext-phar": "*",
"phpunit/phpunit": "^6.2.3",
"zendframework/zend-coding-standard": "^1.0.0",
"zendframework/zend-stdlib": "^2.7 || ^3.0"
},
"suggest": {
"doctrine/annotations": "Doctrine\\Common\\Annotations >=1.0 for annotation features",
"zendframework/zend-stdlib": "Zend\\Stdlib component"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev",
"dev-develop": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\Code\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "provides facilities to generate arbitrary code using an object oriented interface",
"homepage": "https://github.com/zendframework/zend-code",
"keywords": [
"code",
"zf2"
],
"time": "2017-10-20T15:21:32+00:00"
},
{
"name": "zendframework/zend-eventmanager",
"version": "3.2.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-eventmanager.git",
"reference": "a5e2583a211f73604691586b8406ff7296a946dd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/a5e2583a211f73604691586b8406ff7296a946dd",
"reference": "a5e2583a211f73604691586b8406ff7296a946dd",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0"
},
"require-dev": {
"athletic/athletic": "^0.1",
"container-interop/container-interop": "^1.1.0",
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2",
"zendframework/zend-coding-standard": "~1.0.0",
"zendframework/zend-stdlib": "^2.7.3 || ^3.0"
},
"suggest": {
"container-interop/container-interop": "^1.1.0, to use the lazy listeners feature",
"zendframework/zend-stdlib": "^2.7.3 || ^3.0, to use the FilterChain feature"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev",
"dev-develop": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\EventManager\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Trigger and listen to events within a PHP application",
"homepage": "https://github.com/zendframework/zend-eventmanager",
"keywords": [
"event",
"eventmanager",
"events",
"zf2"
],
"time": "2018-04-25T15:33:34+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
@ -3604,16 +4235,16 @@
}, },
{ {
"name": "symfony/flex", "name": "symfony/flex",
"version": "v1.0.82", "version": "v1.0.83",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/flex.git", "url": "https://github.com/symfony/flex.git",
"reference": "729aee08d62b47224e85b83c97e2824ff7d1735e" "reference": "ec42e791e12ca37d73ac37dd8744ef763d39dbbe"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/flex/zipball/729aee08d62b47224e85b83c97e2824ff7d1735e", "url": "https://api.github.com/repos/symfony/flex/zipball/ec42e791e12ca37d73ac37dd8744ef763d39dbbe",
"reference": "729aee08d62b47224e85b83c97e2824ff7d1735e", "reference": "ec42e791e12ca37d73ac37dd8744ef763d39dbbe",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3646,7 +4277,8 @@
"email": "fabien.potencier@gmail.com" "email": "fabien.potencier@gmail.com"
} }
], ],
"time": "2018-05-02T19:08:56+00:00" "description": "Composer plugin for Symfony",
"time": "2018-07-13T07:56:08+00:00"
} }
], ],
"aliases": [], "aliases": [],

View File

@ -11,4 +11,5 @@ return [
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
]; ];

View File

@ -0,0 +1,4 @@
debug:
# Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser.
# See the "server:dump" command to start a new server.
dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%"

View File

@ -17,7 +17,7 @@ doctrine:
money: money money: money
# With Symfony 3.3, remove the `resolve:` prefix # With Symfony 3.3, remove the `resolve:` prefix
url: '%env(resolve:DATABASE_URL)%' url: '%env(DATABASE_URL)%'
orm: orm:
auto_generate_proxy_classes: '%kernel.debug%' auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore naming_strategy: doctrine.orm.naming_strategy.underscore

View File

@ -0,0 +1,5 @@
doctrine_migrations:
dir_name: '%kernel.project_dir%/src/Migrations'
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
namespace: DoctrineMigrations

View File

@ -0,0 +1,3 @@
sensio_framework_extra:
router:
annotations: false

View File

@ -1,3 +0,0 @@
#index:
# path: /
# defaults: { _controller: 'App\Controller\DefaultController::index' }

View File

@ -1,35 +0,0 @@
# Learn more about services, parameters and containers at
# https://symfony.com/doc/current/service_container.html
parameters:
#parameter_name: value
services:
# default configuration for services in *this* file
_defaults:
# automatically injects dependencies in your services
autowire: true
# automatically registers your services as commands, event subscribers, etc.
autoconfigure: true
# this means you cannot fetch services directly from the container via $container->get()
# if you need to do this, you can override this setting on individual services
public: false
# makes classes in src/App available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
# you can exclude directories or files
# but if a service is unused, it's removed anyway
exclude: '../src/{Entity,Repository,Tests}'
# controllers are imported separately to make sure they're public
# and have a tag that allows actions to type-hint services
App\Controller\:
resource: '../src/Controller'
public: true
tags: ['controller.service_arguments']
# add more services, or override services that need manual wiring
# App\Service\ExampleService:
# arguments:
# $someArgument: 'some_value'

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
Table sorting Table sorting
------------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
table th, table th,
.ascend, .ascend,
.descend { .descend {
@ -23,3 +23,10 @@ table thead .descend::before {
table { table {
overflow: scroll; overflow: scroll;
} }
/* ----------------------------------------------------------------------------
Text Areas
---------------------------------------------------------------------------- */
textarea {
height: 12rem;
}

View File

@ -23,7 +23,7 @@ if ($_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev'))) {
// Request::setTrustedProxies(['0.0.0.0/0'], Request::HEADER_FORWARDED); // Request::setTrustedProxies(['0.0.0.0/0'], Request::HEADER_FORWARDED);
$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']); $kernel = new Kernel('dev', true);
$request = Request::createFromGlobals(); $request = Request::createFromGlobals();
$response = $kernel->handle($request); $response = $kernel->handle($request);
$response->send(); $response->send();

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\Camera; use App\Entity\Camera;
use App\Form\CameraType; use App\Form\CameraType;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\ORMInvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
@ -19,6 +18,11 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
class CameraController extends Controller class CameraController extends Controller
{ {
use FormControllerTrait;
protected const ENTITY = Camera::class;
protected const FORM = CameraType::class;
/** /**
* Lists all camera entities. * Lists all camera entities.
* *
@ -26,18 +30,12 @@ class CameraController extends Controller
*/ */
public function indexAction() public function indexAction()
{ {
$em = $this->getDoctrine()->getManager(); return $this->itemListView('camera/index.html.twig','cameras', [
$cameras = $em->getRepository('App:Camera')->findBy([], [
'received' => 'DESC', 'received' => 'DESC',
'brand' => 'ASC', 'brand' => 'ASC',
'mount' => 'ASC', 'mount' => 'ASC',
'model' => 'ASC', 'model' => 'ASC',
]); ]);
return $this->render('camera/index.html.twig', array(
'cameras' => $cameras,
));
} }
/** /**
@ -47,22 +45,7 @@ class CameraController extends Controller
*/ */
public function newAction(Request $request) public function newAction(Request $request)
{ {
$camera = new Camera(); return $this->itemCreate($request, 'camera/new.html.twig', 'camera', 'camera_show');
$form = $this->createForm(CameraType::class, $camera);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($camera);
$em->flush();
return $this->redirectToRoute('camera_show', array('id' => $camera->getId()));
}
return $this->render('camera/new.html.twig', array(
'camera' => $camera,
'form' => $form->createView(),
));
} }
/** /**
@ -72,12 +55,7 @@ class CameraController extends Controller
*/ */
public function showAction(Camera $camera) public function showAction(Camera $camera)
{ {
$deleteForm = $this->createDeleteForm($camera); return $this->itemView($camera, 'camera/show.html.twig', 'camera');
return $this->render('camera/show.html.twig', array(
'camera' => $camera,
'delete_form' => $deleteForm->createView(),
));
} }
/** /**
@ -88,24 +66,7 @@ class CameraController extends Controller
*/ */
public function editAction(Request $request, Camera $camera) public function editAction(Request $request, Camera $camera)
{ {
$deleteForm = $this->createDeleteForm($camera); return $this->itemUpdate($request, $camera, 'camera/edit.html.twig', 'camera', 'camera_show');
$deacquireForm = $this->createDeacquireForm($camera);
$editForm = $this->createForm(CameraType::class, $camera);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('camera_edit', array('id' => $camera->getId()));
}
return $this->render('camera/edit.html.twig', array(
'camera' => $camera,
'edit_form' => $editForm->createView(),
'deacquire_form' => $deacquireForm->createView(),
'delete_form' => $deleteForm->createView(),
));
} }
/** /**
@ -114,16 +75,9 @@ class CameraController extends Controller
* @Route("/{id}", name="camera_delete", methods={"DELETE"}) * @Route("/{id}", name="camera_delete", methods={"DELETE"})
* @throws \LogicException * @throws \LogicException
*/ */
public function deleteAction(Request $request, Camera $camera) public function deleteAction(Request $request, Camera $camera): RedirectResponse
{ {
$form = $this->createDeleteForm($camera); return $this->itemDelete($request, $camera, 'camera_index');
$form->handleRequest($request);
$em = $this->getDoctrine()->getManager();
$em->remove($camera);
$em->flush();
return $this->redirectToRoute('camera_index');
} }
/** /**
@ -133,19 +87,12 @@ class CameraController extends Controller
* @param Request $request * @param Request $request
* @param Camera $camera * @param Camera $camera
* @throws \LogicException * @throws \LogicException
* @throws OptimisticLockException
* @throws ORMInvalidArgumentException * @throws ORMInvalidArgumentException
* @return RedirectResponse * @return RedirectResponse
*/ */
public function deacquireAction(Request $request, Camera $camera): RedirectResponse public function deacquireAction(Request $request, Camera $camera): RedirectResponse
{ {
$form = $this->createDeacquireForm($camera); return $this->itemDeacquire($request, $camera, 'previously-owned-camera_index');
$form->handleRequest($request);
$repository = $this->getDoctrine()->getRepository(Camera::class);
$repository->deacquire($camera);
return $this->redirectToRoute('camera_index');
} }
/** /**
@ -157,10 +104,7 @@ class CameraController extends Controller
*/ */
private function createDeleteForm(Camera $camera): FormInterface private function createDeleteForm(Camera $camera): FormInterface
{ {
return $this->createFormBuilder() return $this->buildForm($camera, 'camera_delete', 'DELETE');
->setAction($this->generateUrl('camera_delete', ['id' => $camera->getId()]))
->setMethod('DELETE')
->getForm();
} }
/** /**
@ -172,9 +116,6 @@ class CameraController extends Controller
*/ */
private function createDeacquireForm(Camera $camera): FormInterface private function createDeacquireForm(Camera $camera): FormInterface
{ {
return $this->createFormBuilder() return $this->buildForm($camera, 'camera_deacquire');
->setAction($this->generateUrl('camera_deacquire', ['id' => $camera->getId()]))
->setMethod('POST')
->getForm();
} }
} }

View File

@ -3,6 +3,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\CameraType; use App\Entity\CameraType;
use App\Form\CameraTypeType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -14,6 +15,11 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
class CameraTypeController extends Controller class CameraTypeController extends Controller
{ {
use FormControllerTrait;
protected const ENTITY = CameraType::class;
protected const FORM = CameraTypeType::class;
/** /**
* Lists all cameraType entities. * Lists all cameraType entities.
* *
@ -21,15 +27,9 @@ class CameraTypeController extends Controller
*/ */
public function indexAction() public function indexAction()
{ {
$em = $this->getDoctrine()->getManager(); return $this->itemListView('cameratype/index.html.twig', 'cameraTypes', [
'type' => 'ASC',
$cameraTypes = $em->getRepository('App:CameraType')->findBy([], [
'type' => 'ASC'
]); ]);
return $this->render('cameratype/index.html.twig', array(
'cameraTypes' => $cameraTypes,
));
} }
/** /**
@ -39,22 +39,7 @@ class CameraTypeController extends Controller
*/ */
public function newAction(Request $request) public function newAction(Request $request)
{ {
$cameraType = new Cameratype(); return $this->itemCreate($request, 'cameratype/new.html.twig', 'cameraType', 'camera-type_show');
$form = $this->createForm('App\Form\CameraTypeType', $cameraType);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($cameraType);
$em->flush();
return $this->redirectToRoute('camera-type_show', array('id' => $cameraType->getId()));
}
return $this->render('cameratype/new.html.twig', array(
'cameraType' => $cameraType,
'form' => $form->createView(),
));
} }
/** /**
@ -64,12 +49,7 @@ class CameraTypeController extends Controller
*/ */
public function showAction(CameraType $cameraType) public function showAction(CameraType $cameraType)
{ {
$deleteForm = $this->createDeleteForm($cameraType); return $this->itemView($cameraType, 'cameratype/show.html.twig', 'cameraType');
return $this->render('cameratype/show.html.twig', array(
'cameraType' => $cameraType,
'delete_form' => $deleteForm->createView(),
));
} }
/** /**
@ -79,21 +59,7 @@ class CameraTypeController extends Controller
*/ */
public function editAction(Request $request, CameraType $cameraType) public function editAction(Request $request, CameraType $cameraType)
{ {
$deleteForm = $this->createDeleteForm($cameraType); return $this->itemUpdate($request, $cameraType, 'cameratype/edit.html.twig', 'cameraType', 'camera-type_show');
$editForm = $this->createForm('App\Form\CameraTypeType', $cameraType);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('camera-type_edit', array('id' => $cameraType->getId()));
}
return $this->render('cameratype/edit.html.twig', array(
'cameraType' => $cameraType,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
} }
/** /**
@ -103,16 +69,7 @@ class CameraTypeController extends Controller
*/ */
public function deleteAction(Request $request, CameraType $cameraType) public function deleteAction(Request $request, CameraType $cameraType)
{ {
$form = $this->createDeleteForm($cameraType); return $this->itemDelete($request, $cameraType, 'camera-type_index');
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($cameraType);
$em->flush();
}
return $this->redirectToRoute('camera-type_index');
} }
/** /**
@ -124,9 +81,6 @@ class CameraTypeController extends Controller
*/ */
private function createDeleteForm(CameraType $cameraType) private function createDeleteForm(CameraType $cameraType)
{ {
return $this->createFormBuilder() return $this->buildForm($cameraType, 'camera-type_delete', 'DELETE');
->setAction($this->generateUrl('camera-type_delete', array('id' => $cameraType->getId())))
->setMethod('DELETE')
->getForm();
} }
} }

View File

@ -16,6 +16,11 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
class FilmController extends Controller class FilmController extends Controller
{ {
use FormControllerTrait;
protected const ENTITY = Film::class;
protected const FORM = FilmType::class;
/** /**
* Lists all film entities. * Lists all film entities.
* *
@ -23,17 +28,12 @@ class FilmController extends Controller
*/ */
public function indexAction() public function indexAction()
{ {
$em = $this->getDoctrine()->getManager(); return $this->itemListView('film/index.html.twig', 'films', [
'rollsInCamera' => 'DESC',
$films = $em->getRepository('App:Film')->findBy([], [
'brand' => 'ASC', 'brand' => 'ASC',
'productLine' => 'ASC', 'productLine' => 'ASC',
'filmFormat' => 'ASC', 'filmFormat' => 'ASC',
]); ]);
return $this->render('film/index.html.twig', array(
'films' => $films,
));
} }
/** /**
@ -43,22 +43,7 @@ class FilmController extends Controller
*/ */
public function newAction(Request $request) public function newAction(Request $request)
{ {
$film = new Film(); return $this->itemCreate($request, 'film/new.html.twig', 'film', 'film_show');
$form = $this->createForm(FilmType::class, $film);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($film);
$em->flush();
return $this->redirectToRoute('film_show', array('id' => $film->getId()));
}
return $this->render('film/new.html.twig', array(
'film' => $film,
'form' => $form->createView(),
));
} }
/** /**
@ -68,12 +53,7 @@ class FilmController extends Controller
*/ */
public function showAction(Film $film) public function showAction(Film $film)
{ {
$deleteForm = $this->createDeleteForm($film); return $this->itemView($film, 'film/show.html.twig', 'film');
return $this->render('film/show.html.twig', array(
'film' => $film,
'delete_form' => $deleteForm->createView(),
));
} }
/** /**
@ -84,22 +64,7 @@ class FilmController extends Controller
*/ */
public function editAction(Request $request, Film $film) public function editAction(Request $request, Film $film)
{ {
$deleteForm = $this->createDeleteForm($film); return $this->itemUpdate($request, $film, 'film/edit.html.twig', 'film', 'film_show');
$editForm = $this->createForm(FilmType::class, $film);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('film_edit', array('id' => $film->getId()));
}
return $this->render('film/edit.html.twig', array(
'film' => $film,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
} }
/** /**
@ -110,14 +75,7 @@ class FilmController extends Controller
*/ */
public function deleteAction(Request $request, Film $film) public function deleteAction(Request $request, Film $film)
{ {
$form = $this->createDeleteForm($film); return $this->itemDelete($request, $film, 'film_index');
$form->handleRequest($request);
$em = $this->getDoctrine()->getManager();
$em->remove($film);
$em->flush();
return $this->redirectToRoute('film_index');
} }
/** /**
@ -129,9 +87,6 @@ class FilmController extends Controller
*/ */
private function createDeleteForm(Film $film): FormInterface private function createDeleteForm(Film $film): FormInterface
{ {
return $this->createFormBuilder() return $this->buildForm($film, 'film_delete', 'DELETE');
->setAction($this->generateUrl('film_delete', ['id' => $film->getId()]))
->setMethod('DELETE')
->getForm();
} }
} }

View File

@ -3,6 +3,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Flash; use App\Entity\Flash;
use App\Form\FlashType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -23,7 +24,7 @@ class FlashController extends Controller
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$flashes = $em->getRepository('App:Flash')->findBy([], [ $flashes = $em->getRepository(Flash::class)->findBy([], [
'received' => 'DESC', 'received' => 'DESC',
'brand' => 'ASC', 'brand' => 'ASC',
'model' => 'ASC' 'model' => 'ASC'
@ -42,7 +43,7 @@ class FlashController extends Controller
public function newAction(Request $request) public function newAction(Request $request)
{ {
$flash = new Flash(); $flash = new Flash();
$form = $this->createForm('App\Form\FlashType', $flash); $form = $this->createForm(FlashType::class, $flash);
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
@ -82,13 +83,13 @@ class FlashController extends Controller
public function editAction(Request $request, Flash $flash) public function editAction(Request $request, Flash $flash)
{ {
$deleteForm = $this->createDeleteForm($flash); $deleteForm = $this->createDeleteForm($flash);
$editForm = $this->createForm('App\Form\FlashType', $flash); $editForm = $this->createForm(FlashType::class, $flash);
$editForm->handleRequest($request); $editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) { if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush(); $this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('flash_edit', array('id' => $flash->getId())); return $this->redirectToRoute('flash_show', array('id' => $flash->getId()));
} }
return $this->render('flash/edit.html.twig', array( return $this->render('flash/edit.html.twig', array(
@ -122,7 +123,7 @@ class FlashController extends Controller
* *
* @param Flash $flash The flash entity * @param Flash $flash The flash entity
* *
* @return \Symfony\Component\Form\Form The form * @return \Symfony\Component\Form\FormInterface The form
*/ */
private function createDeleteForm(Flash $flash) private function createDeleteForm(Flash $flash)
{ {

View File

@ -0,0 +1,167 @@
<?php declare(strict_types=1);
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\{Request, Response, RedirectResponse};
trait FormControllerTrait {
use ControllerTrait;
/**
* Create a form generator
*/
protected function buildForm($item, string $actionRoute, string $method = 'POST'): FormInterface
{
return $this->createFormBuilder()
->setAction($this->generateUrl($actionRoute, ['id' => $item->getId()]))
->setMethod($method)
->getForm();
}
/**
* Show create form / create an item
*/
protected function itemCreate(Request $request, string $template, string $templateKey, string $redirectRoute)
{
$Entity = self::ENTITY;
$item = new $Entity;
$form = $this->createForm(self::FORM, $item);
$form->handleRequest($request);
// If creating the item
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($item);
$em->flush();
return $this->redirectToRoute($redirectRoute, ['id' => $item->getId()]);
}
// If showing the form
return $this->render($template, [
$templateKey => $item,
'form' => $form->createView(),
]);
}
/**
* List view for the data type
*/
protected function itemListView(string $template, string $templateKey, array $sort = []): Response
{
$em = $this->getDoctrine()->getManager();
$items = $em->getRepository(self::ENTITY)->findBy([], $sort);
return $this->render($template, [
$templateKey => $items,
]);
}
/**
* View details for a specific item
*/
protected function itemView($item, string $template, string $templateKey): Response
{
$templateData = [
$templateKey => $item,
];
if (method_exists($this, 'createDeleteForm')) {
$deleteForm = $this->createDeleteForm($item);
$templateData['delete_form'] = $deleteForm->createView();
}
return $this->render($template, $templateData);
}
/**
* Show edit form / update an item
*/
protected function itemUpdate(Request $request, $item, string $template, string $templateKey, string $redirectRoute)
{
$deleteForm = $this->createDeleteForm($item);
$editForm = $this->createForm(self::FORM, $item);
$editForm->handleRequest($request);
// If updating the item
if ($editForm->isSubmitted() && $editForm->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($item);
$em->flush();
return $this->redirectToRoute($redirectRoute, ['id' => $item->getId()]);
}
// If showing the edit form
$templateData = [
$templateKey => $item,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
];
if (method_exists($this, 'createDeacquireForm'))
{
$deacquireForm = $this->createDeacquireForm($item);
$templateData['deacquire_form'] = $deacquireForm->createView();
}
if (method_exists($this, 'createReacquireForm'))
{
$reacquireForm = $this->createReacquireForm($item);
$templateData['reacquire_form'] = $reacquireForm->createView();
}
return $this->render($template, $templateData);
}
/**
* Move an item to a previously_owned table
*/
protected function itemDeacquire(Request $request, $item, string $redirectRoute): RedirectResponse
{
$form = $this->createDeacquireForm($item);
$form->handleRequest($request);
$repository = $this->getDoctrine()->getRepository(self::ENTITY);
$repository->deacquire($item);
return $this->redirectToRoute($redirectRoute);
}
/**
* Move an item from a previously_owned table back to the original table
*/
protected function itemReacquire(Request $request, $item, string $redirectRoute): RedirectResponse
{
$form = $this->createReacquireForm($item);
$form->handleRequest($request);
$repository = $this->getDoctrine()->getRepository(self::ENTITY);
$repository->reacquire($item);
return $this->redirectToRoute($redirectRoute);
}
/**
* Actually delete an item
*/
protected function itemDelete(Request $request, $item, string $redirectRoute): RedirectResponse
{
$form = $this->createDeleteForm($item);
$form->handleRequest($request);
// if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->remove($item);
$em->flush();
}
return $this->redirectToRoute($redirectRoute);
}
}

View File

@ -25,7 +25,7 @@ class LensesController extends Controller
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$lenses = $em->getRepository('App:Lenses')->findBy([], [ $lenses = $em->getRepository(Lenses::class)->findBy([], [
'received' => 'DESC', 'received' => 'DESC',
'brand' => 'ASC', 'brand' => 'ASC',
'productLine' => 'ASC', 'productLine' => 'ASC',

View File

@ -16,6 +16,11 @@ use Symfony\Component\HttpFoundation\{RedirectResponse, Request};
*/ */
class PreviouslyOwnedCameraController extends Controller class PreviouslyOwnedCameraController extends Controller
{ {
use FormControllerTrait;
protected const ENTITY = PreviouslyOwnedCamera::class;
protected const FORM = PreviouslyOwnedCameraType::class;
/** /**
* Lists all previouslyOwnedCamera entities. * Lists all previouslyOwnedCamera entities.
* *
@ -24,17 +29,11 @@ class PreviouslyOwnedCameraController extends Controller
*/ */
public function indexAction() public function indexAction()
{ {
$em = $this->getDoctrine()->getManager(); return $this->itemListView('previouslyownedcamera/index.html.twig', 'previouslyOwnedCameras', [
$previouslyOwnedCameras = $em->getRepository('App:PreviouslyOwnedCamera')->findBy([], [
'brand' => 'ASC', 'brand' => 'ASC',
'mount' => 'ASC', 'mount' => 'ASC',
'model' => 'ASC', 'model' => 'ASC',
]); ]);
return $this->render('previouslyownedcamera/index.html.twig', array(
'previouslyOwnedCameras' => $previouslyOwnedCameras,
));
} }
/** /**
@ -93,7 +92,7 @@ class PreviouslyOwnedCameraController extends Controller
$repository = $this->getDoctrine()->getRepository(PreviouslyOwnedCamera::class); $repository = $this->getDoctrine()->getRepository(PreviouslyOwnedCamera::class);
$repository->reacquire($camera); $repository->reacquire($camera);
return $this->redirectToRoute('previously-owned-camera_index'); return $this->redirectToRoute('camera_index');
} }

View File

@ -3,6 +3,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\PreviouslyOwnedFlash; use App\Entity\PreviouslyOwnedFlash;
use App\Form\PreviouslyOwnedFlashType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -23,7 +24,7 @@ class PreviouslyOwnedFlashController extends Controller
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$previouslyOwnedFlashes = $em->getRepository('App:PreviouslyOwnedFlash')->findBy([], [ $previouslyOwnedFlashes = $em->getRepository(PreviouslyOwnedFlash::class)->findBy([], [
'brand' => 'ASC', 'brand' => 'ASC',
'model' => 'ASC' 'model' => 'ASC'
]); ]);
@ -41,7 +42,7 @@ class PreviouslyOwnedFlashController extends Controller
public function newAction(Request $request) public function newAction(Request $request)
{ {
$previouslyOwnedFlash = new Previouslyownedflash(); $previouslyOwnedFlash = new Previouslyownedflash();
$form = $this->createForm('App\Form\PreviouslyOwnedFlashType', $previouslyOwnedFlash); $form = $this->createForm(PreviouslyOwnedFlashType::class, $previouslyOwnedFlash);
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
@ -77,7 +78,7 @@ class PreviouslyOwnedFlashController extends Controller
*/ */
public function editAction(Request $request, PreviouslyOwnedFlash $previouslyOwnedFlash) public function editAction(Request $request, PreviouslyOwnedFlash $previouslyOwnedFlash)
{ {
$editForm = $this->createForm('App\Form\PreviouslyOwnedFlashType', $previouslyOwnedFlash); $editForm = $this->createForm(PreviouslyOwnedFlashType::class, $previouslyOwnedFlash);
$editForm->handleRequest($request); $editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) { if ($editForm->isSubmitted() && $editForm->isValid()) {

View File

@ -23,7 +23,7 @@ class PreviouslyOwnedLensesController extends Controller
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$previouslyOwnedLenses = $em->getRepository('App:PreviouslyOwnedLenses')->findBy([], [ $previouslyOwnedLenses = $em->getRepository(PreviouslyOwnedLenses::class)->findBy([], [
'brand' => 'ASC', 'brand' => 'ASC',
'productLine' => 'ASC', 'productLine' => 'ASC',
'mount' => 'ASC', 'mount' => 'ASC',

View File

@ -91,7 +91,7 @@ class CameraType
* *
* @return string * @return string
*/ */
public function getType(): string public function getType(): ?string
{ {
return $this->type; return $this->type;
} }

0
src/Migrations/.gitignore vendored Normal file
View File

View File

@ -32,6 +32,18 @@
"doctrine/doctrine-cache-bundle": { "doctrine/doctrine-cache-bundle": {
"version": "1.3.2" "version": "1.3.2"
}, },
"doctrine/doctrine-migrations-bundle": {
"version": "1.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.2",
"ref": "c1431086fec31f17fbcfe6d6d7e92059458facc1"
}
},
"doctrine/event-manager": {
"version": "v1.0.0"
},
"doctrine/inflector": { "doctrine/inflector": {
"version": "v1.2.0" "version": "v1.2.0"
}, },
@ -41,9 +53,18 @@
"doctrine/lexer": { "doctrine/lexer": {
"version": "v1.0.1" "version": "v1.0.1"
}, },
"doctrine/migrations": {
"version": "v1.8.1"
},
"doctrine/orm": { "doctrine/orm": {
"version": "v2.5.13" "version": "v2.5.13"
}, },
"doctrine/persistence": {
"version": "v1.0.0"
},
"doctrine/reflection": {
"version": "v1.0.0"
},
"easycorp/easy-log-handler": { "easycorp/easy-log-handler": {
"version": "1.0", "version": "1.0",
"recipe": { "recipe": {
@ -62,6 +83,12 @@
"nikic/php-parser": { "nikic/php-parser": {
"version": "v4.0.0" "version": "v4.0.0"
}, },
"ocramius/package-versions": {
"version": "1.3.0"
},
"ocramius/proxy-manager": {
"version": "2.2.0"
},
"psr/cache": { "psr/cache": {
"version": "1.0.1" "version": "1.0.1"
}, },
@ -182,6 +209,9 @@
"symfony/options-resolver": { "symfony/options-resolver": {
"version": "v4.0.0" "version": "v4.0.0"
}, },
"symfony/orm-pack": {
"version": "v1.0.5"
},
"symfony/polyfill-ctype": { "symfony/polyfill-ctype": {
"version": "v1.8.0" "version": "v1.8.0"
}, },
@ -241,5 +271,11 @@
}, },
"twig/twig": { "twig/twig": {
"version": "v2.4.4" "version": "v2.4.4"
},
"zendframework/zend-code": {
"version": "3.3.0"
},
"zendframework/zend-eventmanager": {
"version": "3.2.1"
} }
} }

View File

@ -17,21 +17,22 @@
<div class="large primary callout"> <div class="large primary callout">
{{ form_start(edit_form) }} {{ form_start(edit_form) }}
{{ form_widget(edit_form) }} {{ form_widget(edit_form) }}
<button type="submit" class="success button">Update</button> <button type="submit" class="success button expanded">Update</button>
{{ form_end(edit_form) }} {{ form_end(edit_form) }}
<hr /> <div class="grid-x grid-margin-x">
<div class="cell large-6 small-12">
{{ form_start(deacquire_form) }} {{ form_start(deacquire_form) }}
{{ form_widget(deacquire_form) }} {{ form_widget(deacquire_form) }}
<button type="submit" class="button">De-acquire</button> <button type="submit" class="button expanded">De-acquire</button>
{{ form_end(deacquire_form) }} {{ form_end(deacquire_form) }}
</div>
<hr /> <div class="cell large-6 small-12">
{{ form_start(delete_form) }}
{{ form_start(delete_form) }} <button type="submit" class="alert button expanded">Delete</button>
<button type="submit" class="alert button">Delete</button> {{ form_end(delete_form) }}
{{ form_end(delete_form) }} </div>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -16,9 +16,13 @@
</div> </div>
<div class="large primary callout"> <div class="large primary callout">
{{ form_start(form) }} <div class="grid-x grid-margin-x">
{{ form_widget(form) }} <div class="cell medium-12">
<button type="submit" class="success button">Add</button> {{ form_start(form) }}
{{ form_end(form) }} {{ form_widget(form) }}
<button type="submit" class="success button expand">Add</button>
{{ form_end(form) }}
</div>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -10,8 +10,8 @@
{% block body %} {% block body %}
<div class="grid-container"> <div class="grid-container">
<div class="x-grid grid-margin-x"> <div class="grid-x grid-margin-x">
<div class="large-4 medium-6 cell"> <div class="cell large-6 large-offset-2 medium-8 medium-offset-1">
{% block form %}{% endblock %} {% block form %}{% endblock %}
</div> </div>
</div> </div>