Module Recettes : on avance encore...

This commit is contained in:
2021-04-28 20:37:58 +02:00
parent 9976d2ff76
commit 375e4e5d49
26 changed files with 657 additions and 99 deletions

View File

@@ -6,13 +6,22 @@
<forms>
<form name="recette_create_form" class="Recettes\Form\RecetteCreateForm" />
<form name="recette_update_form" class="Recettes\Form\RecetteUpdateForm" />
</forms>
<hooks>
<hook id="recettes.hook" class="Recettes\Hook\HookManager">
<tag name="hook.event_listener" event="content.tab" type="back" method="onEditTab" />
<hook id="recettes.back.hook" class="Recettes\Hook\HookManager">
<tag name="hook.event_listener" event="content.tab" type="back" method="onAddTab" />
</hook>
<hook id="recettes.front.hook" class="Recettes\Hook\HookManager">
<tag name="hook.event_listener" event="content.stylesheet" type="front" method="onAddCSS" />
</hook>
</hooks>
<loops>
<loop name="recipe" class="Recettes\Loop\GeneralLoop"/>
<loop name="recipe_products" class="Recettes\Loop\ProductsLoop"/>
<loop name="recipe_steps" class="Recettes\Loop\StepsLoop"/>
</loops>
</config>

View File

@@ -8,5 +8,4 @@
<default key="_controller">Recettes\Controller\MainController::saveRecipe</default>
</route>
</routes>

View File

@@ -0,0 +1,41 @@
<database defaultIdMethod="native" name="thelia" namespace="Recettes\Model">
<table name="recipe">
<column name="id" autoIncrement="true" primaryKey="true" required="true" type="INTEGER" />
<column name="content_id" type="INTEGER" />
<column name="title" required="true" type="VARCHAR" />
<column name="people" required="true" type="INTEGER" />
<column name="difficulty" required="true" type="INTEGER" />
<column name="preparation_time" required="true" type="VARCHAR" />
<column name="cooking_time" required="false" type="VARCHAR" />
<foreign-key foreignTable="content" name="fk_content_content_id">
<reference foreign="id" local="content_id" />
</foreign-key>
</table>
<table name="recipe_steps">
<column name="recipe_id" required="true" type="INTEGER" />
<column name="step" required="true" type="INTEGER" />
<column name="description" required="true" type="VARCHAR" />
<foreign-key foreignTable="recipe" name="fk_recipesteps_recipe_id">
<reference foreign="id" local="recipe_id" />
</foreign-key>
</table>
<table name="recipe_products">
<column name="recipe_id" required="true" type="INTEGER" />
<column name="pse_id" required="true" type="INTEGER" />
<column name="quantity" required="true" type="INTEGER" />
<foreign-key foreignTable="recipe" name="fk_recipeproducts_recipe_id">
<reference foreign="id" local="recipe_id" />
</foreign-key>
<foreign-key foreignTable="product_sale_elements" name="fk_recipeproducts_pse_id">
<reference foreign="id" local="pse_id" />
</foreign-key>
</table>
<external-schema filename="local/config/schema.xml" referenceOnly="true" />
</database>

View File

@@ -0,0 +1,2 @@
# Sqlfile -> Database map
thelia.sql=thelia

View File

@@ -0,0 +1,67 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- recipe
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `recipe`;
CREATE TABLE `recipe`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`content_id` INTEGER,
`title` VARCHAR(255) NOT NULL,
`people` INTEGER NOT NULL,
`difficulty` INTEGER NOT NULL,
`preparation_time` VARCHAR(255) NOT NULL,
`cooking_time` VARCHAR(255),
PRIMARY KEY (`id`),
INDEX `fi_content_content_id` (`content_id`),
CONSTRAINT `fk_content_content_id`
FOREIGN KEY (`content_id`)
REFERENCES `content` (`id`)
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- recipe_steps
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `recipe_steps`;
CREATE TABLE `recipe_steps`
(
`recipe_id` INTEGER NOT NULL,
`step` INTEGER NOT NULL,
`description` VARCHAR(255) NOT NULL,
INDEX `fi_recipesteps_recipe_id` (`recipe_id`),
CONSTRAINT `fk_recipesteps_recipe_id`
FOREIGN KEY (`recipe_id`)
REFERENCES `recipe` (`id`)
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- recipe_products
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `recipe_products`;
CREATE TABLE `recipe_products`
(
`recipe_id` INTEGER NOT NULL,
`pse_id` INTEGER NOT NULL,
`quantity` INTEGER NOT NULL,
INDEX `fi_recipeproducts_recipe_id` (`recipe_id`),
INDEX `fi_recipeproducts_pse_id` (`pse_id`),
CONSTRAINT `fk_recipeproducts_recipe_id`
FOREIGN KEY (`recipe_id`)
REFERENCES `recipe` (`id`),
CONSTRAINT `fk_recipeproducts_pse_id`
FOREIGN KEY (`pse_id`)
REFERENCES `product_sale_elements` (`id`)
) ENGINE=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;