cruds for products, categories, festivals
This commit is contained in:
parent
0b49351588
commit
d5ef71f734
@ -1,79 +1,45 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Hello !{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<div class="example-wrapper">
|
||||
<h1>Caisse de convention Qzine</h1>
|
||||
<fieldset>
|
||||
<h1>Products list</h1>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<h2>
|
||||
Catégories
|
||||
</h2>
|
||||
{% for c in categories %}
|
||||
<h3>{{ c.name }}</h3>
|
||||
<div class="row-fluid">
|
||||
{% for p in c.products %}
|
||||
<div class="col-xs-6">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Image</th>
|
||||
<th>Price</th>
|
||||
<th>Comment</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for product in products %}
|
||||
<tr>
|
||||
<td><a href="{{ path('product_show', { 'id': product.id }) }}">{{ product.id }}</a></td>
|
||||
<td>{{ product.name }}</td>
|
||||
<td>{{ product.image }}</td>
|
||||
<td>{{ product.price }}</td>
|
||||
<td>{{ product.comment }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('product_show', { 'id': product.id }) }}">show</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('product_edit', { 'id': product.id }) }}">edit</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<button class="btn btn-default btn-block">
|
||||
{{ p.name }}
|
||||
<input type="number" value="{{ p.price }}">
|
||||
€ x
|
||||
|
||||
<span class="badge badge-info">0</span>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<fieldset class="sell">
|
||||
<div class="event-name">
|
||||
<strong>évènement:</strong>
|
||||
<input type="text" value="le salon du livre">
|
||||
</div>
|
||||
<div class="well">
|
||||
<h2>Commentaire</h2>
|
||||
<input type="text" value="le comm">
|
||||
|
||||
</div>
|
||||
<h2>Prix</h2>
|
||||
<strong>
|
||||
<span class="price"></span>
|
||||
€</strong>
|
||||
<button class="btn btn-primary">
|
||||
Enregistrer
|
||||
</button>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<h2>Historique</h2>
|
||||
<ul>
|
||||
<li class="one-sell">
|
||||
12€ - commentaire
|
||||
<button>
|
||||
<i class="fa fa-pencil"></i>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</fieldset>
|
||||
<footer>
|
||||
made by Tykayn -
|
||||
<a href="www.cipherbliss.com">
|
||||
Cipher Bliss
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('product_new') }}">Create a new product</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
@ -1,3 +1,15 @@
|
||||
app_festival:
|
||||
resource: "@AppBundle/Controller/FestivalController.php"
|
||||
type: annotation
|
||||
|
||||
app_product_category:
|
||||
resource: "@AppBundle/Controller/ProductCategoryController.php"
|
||||
type: annotation
|
||||
|
||||
app_product:
|
||||
resource: "@AppBundle/Controller/ProductController.php"
|
||||
type: annotation
|
||||
|
||||
app_sell_record:
|
||||
resource: "@AppBundle/Controller/SellRecordController.php"
|
||||
type: annotation
|
||||
|
@ -118,11 +118,12 @@ class DefaultController extends Controller {
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function addSellingAction( Request $request ) {
|
||||
var_dump( $request->request );
|
||||
// var_dump( $request->request );
|
||||
// die();
|
||||
// link selling record with user, festival
|
||||
// setup dates
|
||||
// persist all
|
||||
// fetch back history of selling
|
||||
return new JsonResponse( [ "message" => "ok" ] );
|
||||
return new JsonResponse( [ "message" => "ok", "dump" => $request->request ] );
|
||||
}
|
||||
}
|
||||
|
136
src/AppBundle/Controller/FestivalController.php
Normal file
136
src/AppBundle/Controller/FestivalController.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Entity\Festival;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Festival controller.
|
||||
*
|
||||
* @Route("festival")
|
||||
*/
|
||||
class FestivalController extends Controller
|
||||
{
|
||||
/**
|
||||
* Lists all festival entities.
|
||||
*
|
||||
* @Route("/", name="festival_index")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$festivals = $em->getRepository('AppBundle:Festival')->findAll();
|
||||
|
||||
return $this->render('festival/index.html.twig', array(
|
||||
'festivals' => $festivals,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new festival entity.
|
||||
*
|
||||
* @Route("/new", name="festival_new")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function newAction(Request $request)
|
||||
{
|
||||
$festival = new Festival();
|
||||
$form = $this->createForm('AppBundle\Form\FestivalType', $festival);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($festival);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('festival_show', array('id' => $festival->getId()));
|
||||
}
|
||||
|
||||
return $this->render('festival/new.html.twig', array(
|
||||
'festival' => $festival,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and displays a festival entity.
|
||||
*
|
||||
* @Route("/{id}", name="festival_show")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function showAction(Festival $festival)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($festival);
|
||||
|
||||
return $this->render('festival/show.html.twig', array(
|
||||
'festival' => $festival,
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing festival entity.
|
||||
*
|
||||
* @Route("/{id}/edit", name="festival_edit")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function editAction(Request $request, Festival $festival)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($festival);
|
||||
$editForm = $this->createForm('AppBundle\Form\FestivalType', $festival);
|
||||
$editForm->handleRequest($request);
|
||||
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('festival_edit', array('id' => $festival->getId()));
|
||||
}
|
||||
|
||||
return $this->render('festival/edit.html.twig', array(
|
||||
'festival' => $festival,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a festival entity.
|
||||
*
|
||||
* @Route("/{id}", name="festival_delete")
|
||||
* @Method("DELETE")
|
||||
*/
|
||||
public function deleteAction(Request $request, Festival $festival)
|
||||
{
|
||||
$form = $this->createDeleteForm($festival);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($festival);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('festival_index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to delete a festival entity.
|
||||
*
|
||||
* @param Festival $festival The festival entity
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm(Festival $festival)
|
||||
{
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('festival_delete', array('id' => $festival->getId())))
|
||||
->setMethod('DELETE')
|
||||
->getForm()
|
||||
;
|
||||
}
|
||||
}
|
136
src/AppBundle/Controller/ProductCategoryController.php
Normal file
136
src/AppBundle/Controller/ProductCategoryController.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Entity\ProductCategory;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Productcategory controller.
|
||||
*
|
||||
* @Route("productcategory")
|
||||
*/
|
||||
class ProductCategoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Lists all productCategory entities.
|
||||
*
|
||||
* @Route("/", name="productcategory_index")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$productCategories = $em->getRepository('AppBundle:ProductCategory')->findAll();
|
||||
|
||||
return $this->render('productcategory/index.html.twig', array(
|
||||
'productCategories' => $productCategories,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new productCategory entity.
|
||||
*
|
||||
* @Route("/new", name="productcategory_new")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function newAction(Request $request)
|
||||
{
|
||||
$productCategory = new Productcategory();
|
||||
$form = $this->createForm('AppBundle\Form\ProductCategoryType', $productCategory);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($productCategory);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('productcategory_show', array('id' => $productCategory->getId()));
|
||||
}
|
||||
|
||||
return $this->render('productcategory/new.html.twig', array(
|
||||
'productCategory' => $productCategory,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and displays a productCategory entity.
|
||||
*
|
||||
* @Route("/{id}", name="productcategory_show")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function showAction(ProductCategory $productCategory)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($productCategory);
|
||||
|
||||
return $this->render('productcategory/show.html.twig', array(
|
||||
'productCategory' => $productCategory,
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing productCategory entity.
|
||||
*
|
||||
* @Route("/{id}/edit", name="productcategory_edit")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function editAction(Request $request, ProductCategory $productCategory)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($productCategory);
|
||||
$editForm = $this->createForm('AppBundle\Form\ProductCategoryType', $productCategory);
|
||||
$editForm->handleRequest($request);
|
||||
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('productcategory_edit', array('id' => $productCategory->getId()));
|
||||
}
|
||||
|
||||
return $this->render('productcategory/edit.html.twig', array(
|
||||
'productCategory' => $productCategory,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a productCategory entity.
|
||||
*
|
||||
* @Route("/{id}", name="productcategory_delete")
|
||||
* @Method("DELETE")
|
||||
*/
|
||||
public function deleteAction(Request $request, ProductCategory $productCategory)
|
||||
{
|
||||
$form = $this->createDeleteForm($productCategory);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($productCategory);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('productcategory_index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to delete a productCategory entity.
|
||||
*
|
||||
* @param ProductCategory $productCategory The productCategory entity
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm(ProductCategory $productCategory)
|
||||
{
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('productcategory_delete', array('id' => $productCategory->getId())))
|
||||
->setMethod('DELETE')
|
||||
->getForm()
|
||||
;
|
||||
}
|
||||
}
|
136
src/AppBundle/Controller/ProductController.php
Normal file
136
src/AppBundle/Controller/ProductController.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Entity\Product;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Product controller.
|
||||
*
|
||||
* @Route("product")
|
||||
*/
|
||||
class ProductController extends Controller
|
||||
{
|
||||
/**
|
||||
* Lists all product entities.
|
||||
*
|
||||
* @Route("/", name="product_index")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$products = $em->getRepository('AppBundle:Product')->findAll();
|
||||
|
||||
return $this->render('product/index.html.twig', array(
|
||||
'products' => $products,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new product entity.
|
||||
*
|
||||
* @Route("/new", name="product_new")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function newAction(Request $request)
|
||||
{
|
||||
$product = new Product();
|
||||
$form = $this->createForm('AppBundle\Form\ProductType', $product);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($product);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('product_show', array('id' => $product->getId()));
|
||||
}
|
||||
|
||||
return $this->render('product/new.html.twig', array(
|
||||
'product' => $product,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and displays a product entity.
|
||||
*
|
||||
* @Route("/{id}", name="product_show")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function showAction(Product $product)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($product);
|
||||
|
||||
return $this->render('product/show.html.twig', array(
|
||||
'product' => $product,
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing product entity.
|
||||
*
|
||||
* @Route("/{id}/edit", name="product_edit")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function editAction(Request $request, Product $product)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($product);
|
||||
$editForm = $this->createForm('AppBundle\Form\ProductType', $product);
|
||||
$editForm->handleRequest($request);
|
||||
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('product_edit', array('id' => $product->getId()));
|
||||
}
|
||||
|
||||
return $this->render('product/edit.html.twig', array(
|
||||
'product' => $product,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a product entity.
|
||||
*
|
||||
* @Route("/{id}", name="product_delete")
|
||||
* @Method("DELETE")
|
||||
*/
|
||||
public function deleteAction(Request $request, Product $product)
|
||||
{
|
||||
$form = $this->createDeleteForm($product);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($product);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('product_index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to delete a product entity.
|
||||
*
|
||||
* @param Product $product The product entity
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm(Product $product)
|
||||
{
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('product_delete', array('id' => $product->getId())))
|
||||
->setMethod('DELETE')
|
||||
->getForm()
|
||||
;
|
||||
}
|
||||
}
|
@ -22,6 +22,12 @@ class Product {
|
||||
*/
|
||||
private $name;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=256)
|
||||
*/
|
||||
private $image;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="ProductCategory", inversedBy="products")
|
||||
*/
|
||||
@ -34,6 +40,20 @@ class Product {
|
||||
use Sellable;
|
||||
use Commentable;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getImage() {
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $image
|
||||
*/
|
||||
public function setImage( $image ) {
|
||||
$this->image = $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
36
src/AppBundle/Form/FestivalType.php
Normal file
36
src/AppBundle/Form/FestivalType.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class FestivalType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('name')->add('dateCreation');
|
||||
}/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'AppBundle\Entity\Festival'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'appbundle_festival';
|
||||
}
|
||||
|
||||
|
||||
}
|
36
src/AppBundle/Form/ProductCategoryType.php
Normal file
36
src/AppBundle/Form/ProductCategoryType.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ProductCategoryType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('name')->add('users');
|
||||
}/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'AppBundle\Entity\ProductCategory'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'appbundle_productcategory';
|
||||
}
|
||||
|
||||
|
||||
}
|
36
src/AppBundle/Form/ProductType.php
Normal file
36
src/AppBundle/Form/ProductType.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ProductType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('name')->add('image')->add('price')->add('comment')->add('category')->add('user');
|
||||
}/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'AppBundle\Entity\Product'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'appbundle_product';
|
||||
}
|
||||
|
||||
|
||||
}
|
55
src/AppBundle/Tests/Controller/FestivalControllerTest.php
Normal file
55
src/AppBundle/Tests/Controller/FestivalControllerTest.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class FestivalControllerTest extends WebTestCase
|
||||
{
|
||||
/*
|
||||
public function testCompleteScenario()
|
||||
{
|
||||
// Create a new client to browse the application
|
||||
$client = static::createClient();
|
||||
|
||||
// Create a new entry in the database
|
||||
$crawler = $client->request('GET', '/festival/');
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /festival/");
|
||||
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
|
||||
|
||||
// Fill in the form and submit it
|
||||
$form = $crawler->selectButton('Create')->form(array(
|
||||
'appbundle_festival[field_name]' => 'Test',
|
||||
// ... other fields to fill
|
||||
));
|
||||
|
||||
$client->submit($form);
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check data in the show view
|
||||
$this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")');
|
||||
|
||||
// Edit the entity
|
||||
$crawler = $client->click($crawler->selectLink('Edit')->link());
|
||||
|
||||
$form = $crawler->selectButton('Update')->form(array(
|
||||
'appbundle_festival[field_name]' => 'Foo',
|
||||
// ... other fields to fill
|
||||
));
|
||||
|
||||
$client->submit($form);
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check the element contains an attribute with value equals "Foo"
|
||||
$this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]');
|
||||
|
||||
// Delete the entity
|
||||
$client->submit($crawler->selectButton('Delete')->form());
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check the entity has been delete on the list
|
||||
$this->assertNotRegExp('/Foo/', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class ProductCategoryControllerTest extends WebTestCase
|
||||
{
|
||||
/*
|
||||
public function testCompleteScenario()
|
||||
{
|
||||
// Create a new client to browse the application
|
||||
$client = static::createClient();
|
||||
|
||||
// Create a new entry in the database
|
||||
$crawler = $client->request('GET', '/productcategory/');
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /productcategory/");
|
||||
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
|
||||
|
||||
// Fill in the form and submit it
|
||||
$form = $crawler->selectButton('Create')->form(array(
|
||||
'appbundle_productcategory[field_name]' => 'Test',
|
||||
// ... other fields to fill
|
||||
));
|
||||
|
||||
$client->submit($form);
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check data in the show view
|
||||
$this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")');
|
||||
|
||||
// Edit the entity
|
||||
$crawler = $client->click($crawler->selectLink('Edit')->link());
|
||||
|
||||
$form = $crawler->selectButton('Update')->form(array(
|
||||
'appbundle_productcategory[field_name]' => 'Foo',
|
||||
// ... other fields to fill
|
||||
));
|
||||
|
||||
$client->submit($form);
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check the element contains an attribute with value equals "Foo"
|
||||
$this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]');
|
||||
|
||||
// Delete the entity
|
||||
$client->submit($crawler->selectButton('Delete')->form());
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check the entity has been delete on the list
|
||||
$this->assertNotRegExp('/Foo/', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
55
src/AppBundle/Tests/Controller/ProductControllerTest.php
Normal file
55
src/AppBundle/Tests/Controller/ProductControllerTest.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class ProductControllerTest extends WebTestCase
|
||||
{
|
||||
/*
|
||||
public function testCompleteScenario()
|
||||
{
|
||||
// Create a new client to browse the application
|
||||
$client = static::createClient();
|
||||
|
||||
// Create a new entry in the database
|
||||
$crawler = $client->request('GET', '/product/');
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /product/");
|
||||
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
|
||||
|
||||
// Fill in the form and submit it
|
||||
$form = $crawler->selectButton('Create')->form(array(
|
||||
'appbundle_product[field_name]' => 'Test',
|
||||
// ... other fields to fill
|
||||
));
|
||||
|
||||
$client->submit($form);
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check data in the show view
|
||||
$this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")');
|
||||
|
||||
// Edit the entity
|
||||
$crawler = $client->click($crawler->selectLink('Edit')->link());
|
||||
|
||||
$form = $crawler->selectButton('Update')->form(array(
|
||||
'appbundle_product[field_name]' => 'Foo',
|
||||
// ... other fields to fill
|
||||
));
|
||||
|
||||
$client->submit($form);
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check the element contains an attribute with value equals "Foo"
|
||||
$this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]');
|
||||
|
||||
// Delete the entity
|
||||
$client->submit($crawler->selectButton('Delete')->form());
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check the entity has been delete on the list
|
||||
$this->assertNotRegExp('/Foo/', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
Loading…
Reference in New Issue
Block a user