listing products by category

This commit is contained in:
Ty Kayn 2018-03-15 16:31:12 +01:00
parent ac1c0597ba
commit 6ebeeb723f
10 changed files with 295 additions and 117 deletions

2
.idea/php.xml generated
View File

@ -91,6 +91,8 @@
<path value="$PROJECT_DIR$/vendor/symfony/dependency-injection" />
<path value="$PROJECT_DIR$/vendor/symfony/browser-kit" />
<path value="$PROJECT_DIR$/vendor/symfony/validator" />
<path value="$PROJECT_DIR$/vendor/doctrine/data-fixtures" />
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-fixtures-bundle" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7" />

2
.idea/sf4-test.iml generated
View File

@ -9,9 +9,11 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/cache" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/collections" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/common" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/data-fixtures" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/dbal" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/doctrine-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/doctrine-cache-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/doctrine-fixtures-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/doctrine-migrations-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/inflector" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/instantiator" />

195
.idea/workspace.xml generated
View File

@ -2,10 +2,15 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="77eba199-b6d3-40aa-8673-48ccff359364" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/php.xml" afterPath="$PROJECT_DIR$/.idea/php.xml" />
<change beforePath="$PROJECT_DIR$/.idea/sf4-test.iml" afterPath="$PROJECT_DIR$/.idea/sf4-test.iml" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/src/Entity/Product.php" afterPath="$PROJECT_DIR$/src/Entity/Product.php" />
<change beforePath="$PROJECT_DIR$/src/Entity/ProductCategory.php" afterPath="$PROJECT_DIR$/src/Entity/ProductCategory.php" />
<change beforePath="$PROJECT_DIR$/src/Entity/SellRecord.php" afterPath="$PROJECT_DIR$/src/Entity/SellRecord.php" />
<change beforePath="$PROJECT_DIR$/composer.json" afterPath="$PROJECT_DIR$/composer.json" />
<change beforePath="$PROJECT_DIR$/composer.lock" afterPath="$PROJECT_DIR$/composer.lock" />
<change beforePath="$PROJECT_DIR$/config/bundles.php" afterPath="$PROJECT_DIR$/config/bundles.php" />
<change beforePath="$PROJECT_DIR$/src/Controller/ProductController.php" afterPath="$PROJECT_DIR$/src/Controller/ProductController.php" />
<change beforePath="$PROJECT_DIR$/symfony.lock" afterPath="$PROJECT_DIR$/symfony.lock" />
<change beforePath="$PROJECT_DIR$/templates/product/index.html.twig" afterPath="$PROJECT_DIR$/templates/product/index.html.twig" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -29,23 +34,23 @@
</provider>
</entry>
</file>
<file leaf-file-name="console" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/bin/console">
<file leaf-file-name="ProductController.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/Controller/ProductController.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1560">
<caret line="3" column="4" lean-forward="false" selection-start-line="3" selection-start-column="4" selection-end-line="3" selection-end-column="4" />
<state relative-caret-position="390">
<caret line="30" column="48" lean-forward="false" selection-start-line="30" selection-start-column="48" selection-end-line="30" selection-end-column="48" />
<folding>
<element signature="e#26#41#0#PHP" expanded="true" />
<element signature="e#906#931#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Product.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Entity/Product.php">
<file leaf-file-name="index.html.twig" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/templates/product/index.html.twig">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="453">
<caret line="31" column="45" lean-forward="false" selection-start-line="31" selection-start-column="45" selection-end-line="31" selection-end-column="45" />
<state relative-caret-position="0">
<caret line="0" column="21" lean-forward="false" selection-start-line="0" selection-start-column="21" selection-end-line="0" selection-end-column="21" />
<folding />
</state>
</provider>
@ -54,8 +59,8 @@
<file leaf-file-name="base.html.twig" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/templates/base.html.twig">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="650">
<caret line="10" column="36" lean-forward="false" selection-start-line="10" selection-start-column="36" selection-end-line="10" selection-end-column="36" />
<state relative-caret-position="910">
<caret line="14" column="7" lean-forward="false" selection-start-line="14" selection-start-column="7" selection-end-line="14" selection-end-column="7" />
<folding />
</state>
</provider>
@ -64,28 +69,8 @@
<file leaf-file-name="ProductCategory.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Entity/ProductCategory.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="388">
<caret line="25" column="22" lean-forward="false" selection-start-line="25" selection-start-column="22" selection-end-line="25" selection-end-column="22" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name=".env" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/.env">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="520">
<caret line="22" column="61" lean-forward="false" selection-start-line="22" selection-start-column="61" selection-end-line="22" selection-end-column="61" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="doctrine.yaml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/config/packages/doctrine.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-195">
<caret line="12" column="24" lean-forward="false" selection-start-line="12" selection-start-column="24" selection-end-line="12" selection-end-column="24" />
<state relative-caret-position="1098">
<caret line="28" column="20" lean-forward="false" selection-start-line="28" selection-start-column="20" selection-end-line="28" selection-end-column="20" />
<folding />
</state>
</provider>
@ -108,12 +93,13 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/Controller/ProductController.php" />
<option value="$PROJECT_DIR$/templates/base.html.twig" />
<option value="$PROJECT_DIR$/.env" />
<option value="$PROJECT_DIR$/src/Entity/Product.php" />
<option value="$PROJECT_DIR$/src/Entity/ProductCategory.php" />
<option value="$PROJECT_DIR$/src/Entity/SellRecord.php" />
<option value="$PROJECT_DIR$/templates/product/index.html.twig" />
<option value="$PROJECT_DIR$/src/Controller/ProductController.php" />
</list>
</option>
</component>
@ -128,6 +114,9 @@
<component name="NodeModulesDirectoryManager">
<handled-path value="$PROJECT_DIR$/node_modules" />
</component>
<component name="PhpServers">
<servers />
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" interpreter_name="PHP 5.5">
<include_path>
<path value="$PROJECT_DIR$/vendor/symfony/dom-crawler" />
@ -219,6 +208,8 @@
<path value="$PROJECT_DIR$/vendor/symfony/dependency-injection" />
<path value="$PROJECT_DIR$/vendor/symfony/browser-kit" />
<path value="$PROJECT_DIR$/vendor/symfony/validator" />
<path value="$PROJECT_DIR$/vendor/doctrine/data-fixtures" />
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-fixtures-bundle" />
</include_path>
</component>
<component name="ProjectFrameBounds" extendedState="6">
@ -273,6 +264,19 @@
<item name="config" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="packages" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="sf4-test" type="b2602c69:ProjectViewProjectNode" />
<item name="sf4-test" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="config" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="routes" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="sf4-test" type="b2602c69:ProjectViewProjectNode" />
<item name="sf4-test" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="config" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="routes" type="2a2b976b:PhpTreeStructureProvider$1" />
<item name="dev" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
<path>
<item name="sf4-test" type="b2602c69:ProjectViewProjectNode" />
<item name="sf4-test" type="2a2b976b:PhpTreeStructureProvider$1" />
@ -364,22 +368,23 @@
<updated>1520949897852</updated>
<workItem from="1520949899279" duration="654000" />
<workItem from="1521124630756" duration="815000" />
<workItem from="1521125457191" duration="1508000" />
<workItem from="1521125457191" duration="2395000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="2977000" />
<option name="totallyTimeSpent" value="3864000" />
</component>
<component name="ToolWindowManager">
<frame x="1046" y="436" width="3761" height="2166" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32984293" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32984293" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32984293" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Remote Host" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.124828905" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@ -534,14 +539,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config/packages/routing.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config/packages/twig.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
@ -598,34 +595,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Controller/ProductController.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="581">
<caret line="33" column="43" lean-forward="false" selection-start-line="33" selection-start-column="43" selection-end-line="33" selection-end-column="43" />
<folding>
<element signature="e#34#57#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/product/index.html.twig">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="e#12#26#0#Twig" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/base.html.twig">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="650">
<caret line="10" column="36" lean-forward="false" selection-start-line="10" selection-start-column="36" selection-end-line="10" selection-end-column="36" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Repository/SellRecordRepository.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-780">
@ -642,20 +611,34 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/bin/console">
<entry file="file://$PROJECT_DIR$/.env">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1560">
<caret line="3" column="4" lean-forward="false" selection-start-line="3" selection-start-column="4" selection-end-line="3" selection-end-column="4" />
<folding>
<element signature="e#26#41#0#PHP" expanded="true" />
</folding>
<state relative-caret-position="455">
<caret line="21" column="47" lean-forward="false" selection-start-line="21" selection-start-column="47" selection-end-line="21" selection-end-column="47" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Entity/ProductCategory.php">
<entry file="file://$PROJECT_DIR$/config/packages/routing.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="388">
<caret line="25" column="22" lean-forward="false" selection-start-line="25" selection-start-column="22" selection-end-line="25" selection-end-column="22" />
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config/routes/dev/twig.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config/routes/annotations.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
@ -668,6 +651,16 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/bin/console">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1560">
<caret line="3" column="4" lean-forward="false" selection-start-line="3" selection-start-column="4" selection-end-line="3" selection-end-column="4" />
<folding>
<element signature="e#26#41#0#PHP" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Entity/SellRecord.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="650">
@ -676,13 +669,39 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.env">
<entry file="file://$PROJECT_DIR$/src/Entity/ProductCategory.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="520">
<caret line="22" column="61" lean-forward="false" selection-start-line="22" selection-start-column="61" selection-end-line="22" selection-end-column="61" />
<state relative-caret-position="1098">
<caret line="28" column="20" lean-forward="false" selection-start-line="28" selection-start-column="20" selection-end-line="28" selection-end-column="20" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/product/index.html.twig">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="21" lean-forward="false" selection-start-line="0" selection-start-column="21" selection-end-line="0" selection-end-column="21" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/templates/base.html.twig">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="910">
<caret line="14" column="7" lean-forward="false" selection-start-line="14" selection-start-column="7" selection-end-line="14" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Controller/ProductController.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="390">
<caret line="30" column="48" lean-forward="false" selection-start-line="30" selection-start-column="48" selection-end-line="30" selection-end-column="48" />
<folding>
<element signature="e#906#931#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View File

@ -25,6 +25,7 @@
"symfony/yaml": "^3.4"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0",
"symfony/browser-kit": "^3.4",
"symfony/css-selector": "^3.4",
"symfony/dotenv": "^3.4",

122
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "f622f00afd59c3a14e9d36ccff4cdc4e",
"content-hash": "ed6ed212a7401fdb77a64ea454462831",
"packages": [
{
"name": "doctrine/annotations",
@ -5232,6 +5232,126 @@
}
],
"packages-dev": [
{
"name": "doctrine/data-fixtures",
"version": "v1.2.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/data-fixtures.git",
"reference": "17fa5bfe6ff52e35cb3d9ec37c934a2f4bd1fa2e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/data-fixtures/zipball/17fa5bfe6ff52e35cb3d9ec37c934a2f4bd1fa2e",
"reference": "17fa5bfe6ff52e35cb3d9ec37c934a2f4bd1fa2e",
"shasum": ""
},
"require": {
"doctrine/common": "~2.2",
"php": "^5.6 || ^7.0"
},
"conflict": {
"doctrine/orm": "< 2.4"
},
"require-dev": {
"doctrine/dbal": "^2.5.4",
"doctrine/orm": "^2.5.4",
"phpunit/phpunit": "^5.4.6"
},
"suggest": {
"doctrine/mongodb-odm": "For loading MongoDB ODM fixtures",
"doctrine/orm": "For loading ORM fixtures",
"doctrine/phpcr-odm": "For loading PHPCR ODM fixtures"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
},
"autoload": {
"psr-0": {
"Doctrine\\Common\\DataFixtures": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
}
],
"description": "Data Fixtures for all Doctrine Object Managers",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"database"
],
"time": "2016-09-20T10:07:57+00:00"
},
{
"name": "doctrine/doctrine-fixtures-bundle",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/DoctrineFixturesBundle.git",
"reference": "7fc29d2b18c61ed99826b21fbfd1ff9969cc2e7f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/7fc29d2b18c61ed99826b21fbfd1ff9969cc2e7f",
"reference": "7fc29d2b18c61ed99826b21fbfd1ff9969cc2e7f",
"shasum": ""
},
"require": {
"doctrine/data-fixtures": "~1.0",
"doctrine/doctrine-bundle": "~1.0",
"php": ">=5.5.9|^7.0",
"symfony/doctrine-bridge": "~2.7|~3.0|~4.0",
"symfony/framework-bundle": "^3.3|^4.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^3.3"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Bundle\\FixturesBundle\\": ""
}
},
"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 DoctrineFixturesBundle",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"Fixture",
"persistence"
],
"time": "2017-12-04T20:26:38+00:00"
},
{
"name": "symfony/browser-kit",
"version": "v3.4.6",

View File

@ -13,4 +13,5 @@ return [
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
];

View File

@ -3,37 +3,32 @@
namespace App\Controller;
use App\Entity\Product;
use App\Entity\ProductCategory;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ProductController extends Controller {
/**
* @Route("/product", name="product")
* @Route("/", name="product")
*/
public function index() {
$allProducts = $this->getDoctrine()
->getRepository( Product::class )
->findAll();
$allProducts = $this->getDoctrine()
->getRepository( Product::class )
->findAll();
$allCategories = $this->getDoctrine()
->getRepository( ProductCategory::class )
->findAll();
// you can fetch the EntityManager via $this->getDoctrine()
// or you can add an argument to your action: index(EntityManagerInterface $entityManager)
$entityManager = $this->getDoctrine()->getManager();
// $entityManager = $this->getDoctrine()->getManager();
$product = new Product();
$product->setName( 'qzine n°spécial 1' );
$product->setPrice( 19.99 );
// tell Doctrine you want to (eventually) save the Product (no queries yet)
$entityManager->persist( $product );
// actually executes the queries (i.e. the INSERT query)
$entityManager->flush();
// return new Response( 'Saved new product with id ' . $product->getId() );
return $this->render( 'product/index.html.twig',
[
'product' => $product,
'categories' => $allCategories,
'allProducts' => $allProducts,
] );
}

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

View File

@ -17,6 +17,9 @@
"doctrine/common": {
"version": "v2.7.3"
},
"doctrine/data-fixtures": {
"version": "v1.2.2"
},
"doctrine/dbal": {
"version": "v2.5.13"
},
@ -32,6 +35,15 @@
"doctrine/doctrine-cache-bundle": {
"version": "1.3.2"
},
"doctrine/doctrine-fixtures-bundle": {
"version": "3.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.0",
"ref": "2ea6070ecf365f9a801ccaed4b31d4a3b7af5693"
}
},
"doctrine/doctrine-migrations-bundle": {
"version": "1.2",
"recipe": {

View File

@ -1,20 +1,46 @@
{% extends 'base.html.twig' %}
{% block title %}Hello {{ controller_name }}!{% endblock %}
{% block title %}Hello !{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<style>
.example-wrapper {
margin: 1em auto;
max-width: 800px;
width: 95%;
font: 18px/1.5 sans-serif;
}
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
.example-wrapper code {
background: #F5F5F5;
padding: 2px 6px;
}
</style>
This friendly message is coming from:
<ul>
<li>Your controller at <code>src/Controller/ProductController.php</code></li>
<li>Your template at <code>templates/product/index.html.twig</code></li>
</ul>
</div>
<div class="example-wrapper">
<h1>Hello ! ✅</h1>
<fieldset>
<h2>
Catégories
</h2>
{% for c in categories %}
<h3>{{ c.name }}</h3>
{% for p in c.products %}
<button class="btn btn-default">
{{ p.name }}
</button>
{% endfor %}
{% endfor %}
</fieldset>
<footer>
This friendly message is coming from:
<ul>
<li>Your controller at <code>src/Controller/ProductController.php</code></li>
<li>Your template at <code>templates/product/index.html.twig</code></li>
</ul>
</footer>
</div>
{% endblock %}