set current user by default

This commit is contained in:
Kayn Ty 2018-04-17 15:41:00 +02:00
parent 0d7b46f5f1
commit 80b334cf85
19 changed files with 500 additions and 352 deletions

View File

@ -30,6 +30,13 @@
Produits Produits
</a> </a>
</li> </li>
<li>
<a class="btn btn-default" href="{{ path('festival_index') }}"
data-toggle="tab">
<i class="fa fa-hat"></i>
Festivals
</a>
</li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -5,7 +5,7 @@
{{ form_start(form) }} {{ form_start(form) }}
{{ form_widget(form) }} {{ form_widget(form) }}
<input type="submit" value="Create" /> <input class="btn btn-primary btn-block" type="submit" value="Créer" />
{{ form_end(form) }} {{ form_end(form) }}
<ul> <ul>

View File

@ -5,7 +5,7 @@
</h2> </h2>
<button ng-repeat="p in c.products track by p.id" <button ng-repeat="p in c.products track by p.id"
class="btn btn-default" class="btn btn-default"
ng-class="{ 'btn-primary' : activeItemsSold.indexOf(p.id)}" ng-class="{ 'btn-primary' : activeItemsSold.indexOf(p.id) !==-1}"
ng-click="addProduct( p )"> ng-click="addProduct( p )">
<span class="product-name"> <span class="product-name">
{{ p.name }} {{ p.name }}

View File

@ -5,7 +5,7 @@
{{ form_start(form) }} {{ form_start(form) }}
{{ form_widget(form) }} {{ form_widget(form) }}
<input type="submit" value="Create"/> <input type="submit" class="btn btn-primary btn-block" value="Créer"/>
{{ form_end(form) }} {{ form_end(form) }}
<ul> <ul>

View File

@ -5,7 +5,7 @@
{{ form_start(form) }} {{ form_start(form) }}
{{ form_widget(form) }} {{ form_widget(form) }}
<input type="submit" value="Create" /> <input type="submit" class="btn btn-primary btn-block" value="Créer" />
{{ form_end(form) }} {{ form_end(form) }}
<ul> <ul>

View File

@ -4,13 +4,16 @@
<h1>Sellrecord creation</h1> <h1>Sellrecord creation</h1>
{{ form_start(form) }} {{ form_start(form) }}
{{ form_widget(form) }} {{ form_widget(form) }}
<input type="submit" value="Create" /> <input type="submit" class="btn btn-primary btn-block" value="Créer"/>
{{ form_end(form) }} {{ form_end(form) }}
<ul> <ul>
<li> <li>
<a class="btn btn-primary" href="{{ path('sellrecord_index') }}"> <i class="fa fa-arrow-left"></i>Retour à la liste</a> <a class="btn btn-primary" href="{{ path('sellrecord_index') }}">
<i class="fa fa-arrow-left"></i>
Retour à la liste
</a>
</li> </li>
</ul> </ul>
{% endblock %} {% endblock %}

View File

@ -22,3 +22,8 @@ thead {
ul { ul {
padding: 0; padding: 0;
} }
label {
min-width: 20em;
display: inline-block;
}

View File

@ -3,134 +3,133 @@
namespace AppBundle\Controller; namespace AppBundle\Controller;
use AppBundle\Entity\Festival; use AppBundle\Entity\Festival;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
/** /**
* Festival controller. * Festival controller.
* *
* @Route("festival") * @Route("festival")
*/ */
class FestivalController extends Controller class FestivalController extends Controller {
{ /**
/** * Lists all festival entities.
* Lists all festival entities. *
* * @Route("/", name="festival_index")
* @Route("/", name="festival_index") * @Method("GET")
* @Method("GET") */
*/ public function indexAction() {
public function indexAction() $em = $this->getDoctrine()->getManager();
{
$em = $this->getDoctrine()->getManager();
$festivals = $em->getRepository('AppBundle:Festival')->findAll(); $festivals = $em->getRepository( 'AppBundle:Festival' )->findByUser($this->getUser() );
return $this->render('festival/index.html.twig', array( return $this->render( 'festival/index.html.twig',
'festivals' => $festivals, [
)); 'festivals' => $festivals,
} ] );
}
/** /**
* Creates a new festival entity. * Creates a new festival entity.
* *
* @Route("/new", name="festival_new") * @Route("/new", name="festival_new")
* @Method({"GET", "POST"}) * @Method({"GET", "POST"})
*/ */
public function newAction(Request $request) public function newAction( Request $request ) {
{ $festival = new Festival();
$festival = new Festival(); $festival->setUser( $this->getUser() );
$form = $this->createForm('AppBundle\Form\FestivalType', $festival); $festival->setDateCreation(new \DateTime());
$form->handleRequest($request); $form = $this->createForm( 'AppBundle\Form\FestivalType', $festival );
$form->handleRequest( $request );
if ($form->isSubmitted() && $form->isValid()) { if ( $form->isSubmitted() && $form->isValid() ) {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist($festival); $em->persist( $festival );
$em->flush(); $em->flush();
return $this->redirectToRoute('festival_show', array('id' => $festival->getId())); return $this->redirectToRoute( 'festival_show', [ 'id' => $festival->getId() ] );
} }
return $this->render('festival/new.html.twig', array( return $this->render( 'festival/new.html.twig',
'festival' => $festival, [
'form' => $form->createView(), 'festival' => $festival,
)); 'form' => $form->createView(),
} ] );
}
/** /**
* Finds and displays a festival entity. * Finds and displays a festival entity.
* *
* @Route("/{id}", name="festival_show") * @Route("/{id}", name="festival_show")
* @Method("GET") * @Method("GET")
*/ */
public function showAction(Festival $festival) public function showAction( Festival $festival ) {
{ $deleteForm = $this->createDeleteForm( $festival );
$deleteForm = $this->createDeleteForm($festival);
return $this->render('festival/show.html.twig', array( return $this->render( 'festival/show.html.twig',
'festival' => $festival, [
'delete_form' => $deleteForm->createView(), 'festival' => $festival,
)); 'delete_form' => $deleteForm->createView(),
} ] );
}
/** /**
* Displays a form to edit an existing festival entity. * Displays a form to edit an existing festival entity.
* *
* @Route("/{id}/edit", name="festival_edit") * @Route("/{id}/edit", name="festival_edit")
* @Method({"GET", "POST"}) * @Method({"GET", "POST"})
*/ */
public function editAction(Request $request, Festival $festival) public function editAction( Request $request, Festival $festival ) {
{ $deleteForm = $this->createDeleteForm( $festival );
$deleteForm = $this->createDeleteForm($festival); $editForm = $this->createForm( 'AppBundle\Form\FestivalType', $festival );
$editForm = $this->createForm('AppBundle\Form\FestivalType', $festival); $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('festival_edit', array('id' => $festival->getId())); return $this->redirectToRoute( 'festival_edit', [ 'id' => $festival->getId() ] );
} }
return $this->render('festival/edit.html.twig', array( return $this->render( 'festival/edit.html.twig',
'festival' => $festival, [
'edit_form' => $editForm->createView(), 'festival' => $festival,
'delete_form' => $deleteForm->createView(), 'edit_form' => $editForm->createView(),
)); 'delete_form' => $deleteForm->createView(),
} ] );
}
/** /**
* Deletes a festival entity. * Deletes a festival entity.
* *
* @Route("/{id}", name="festival_delete") * @Route("/{id}", name="festival_delete")
* @Method("DELETE") * @Method("DELETE")
*/ */
public function deleteAction(Request $request, Festival $festival) public function deleteAction( Request $request, Festival $festival ) {
{ $form = $this->createDeleteForm( $festival );
$form = $this->createDeleteForm($festival); $form->handleRequest( $request );
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ( $form->isSubmitted() && $form->isValid() ) {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->remove($festival); $em->remove( $festival );
$em->flush(); $em->flush();
} }
return $this->redirectToRoute('festival_index'); return $this->redirectToRoute( 'festival_index' );
} }
/** /**
* Creates a form to delete a festival entity. * Creates a form to delete a festival entity.
* *
* @param Festival $festival The festival entity * @param Festival $festival The festival entity
* *
* @return \Symfony\Component\Form\Form The form * @return \Symfony\Component\Form\Form The form
*/ */
private function createDeleteForm(Festival $festival) private function createDeleteForm( Festival $festival ) {
{ return $this->createFormBuilder()
return $this->createFormBuilder() ->setAction( $this->generateUrl( 'festival_delete', [ 'id' => $festival->getId() ] ) )
->setAction($this->generateUrl('festival_delete', array('id' => $festival->getId()))) ->setMethod( 'DELETE' )
->setMethod('DELETE') ->getForm();
->getForm() }
;
}
} }

View File

@ -39,6 +39,7 @@ class ProductCategoryController extends Controller {
*/ */
public function newAction( Request $request ) { public function newAction( Request $request ) {
$productCategory = new Productcategory(); $productCategory = new Productcategory();
$productCategory->setUsers($this->getUser());
$form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory ); $form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
$form->handleRequest( $request ); $form->handleRequest( $request );

View File

@ -24,7 +24,7 @@ class ProductController extends Controller
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$products = $em->getRepository('AppBundle:Product')->findAll(); $products = $em->getRepository('AppBundle:Product')->findByUser($this->getUser() );
return $this->render('product/index.html.twig', array( return $this->render('product/index.html.twig', array(
'products' => $products, 'products' => $products,
@ -40,6 +40,7 @@ class ProductController extends Controller
public function newAction(Request $request) public function newAction(Request $request)
{ {
$product = new Product(); $product = new Product();
$product->setUser($this->getUser());
$form = $this->createForm('AppBundle\Form\ProductType', $product); $form = $this->createForm('AppBundle\Form\ProductType', $product);
$form->handleRequest($request); $form->handleRequest($request);

View File

@ -24,7 +24,7 @@ class SellRecordController extends Controller
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$sellRecords = $em->getRepository('AppBundle:SellRecord')->findAll(); $sellRecords = $em->getRepository('AppBundle:SellRecord')->findByUser($this->getUser() );
return $this->render('sellrecord/index.html.twig', array( return $this->render('sellrecord/index.html.twig', array(
'sellRecords' => $sellRecords, 'sellRecords' => $sellRecords,
@ -40,6 +40,7 @@ class SellRecordController extends Controller
public function newAction(Request $request) public function newAction(Request $request)
{ {
$sellRecord = new Sellrecord(); $sellRecord = new Sellrecord();
$sellRecord->setUser($this->getUser());
$form = $this->createForm('AppBundle\Form\SellRecordType', $sellRecord); $form = $this->createForm('AppBundle\Form\SellRecordType', $sellRecord);
$form->handleRequest($request); $form->handleRequest($request);

View File

@ -41,6 +41,10 @@ class Festival {
*/ */
private $sellRecords; private $sellRecords;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="festivals")
*/
private $user;
/** /**
* Get id * Get id
@ -116,35 +120,55 @@ class Festival {
public function getSellRecords() { public function getSellRecords() {
return $this->sellRecords; return $this->sellRecords;
} }
/**
* Constructor
*/
public function __construct()
{
$this->sellRecords = new \Doctrine\Common\Collections\ArrayCollection();
}
/** /**
* Add sellRecord * Constructor
* */
* @param \AppBundle\Entity\SellRecord $sellRecord public function __construct() {
* $this->sellRecords = new \Doctrine\Common\Collections\ArrayCollection();
* @return Festival }
*/
public function addSellRecord(\AppBundle\Entity\SellRecord $sellRecord)
{
$this->sellRecords[] = $sellRecord;
return $this; /**
} * Add sellRecord
*
* @param \AppBundle\Entity\SellRecord $sellRecord
*
* @return Festival
*/
public function addSellRecord( \AppBundle\Entity\SellRecord $sellRecord ) {
$this->sellRecords[] = $sellRecord;
/** return $this;
* Remove sellRecord }
*
* @param \AppBundle\Entity\SellRecord $sellRecord /**
*/ * Remove sellRecord
public function removeSellRecord(\AppBundle\Entity\SellRecord $sellRecord) *
{ * @param \AppBundle\Entity\SellRecord $sellRecord
$this->sellRecords->removeElement($sellRecord); */
} public function removeSellRecord( \AppBundle\Entity\SellRecord $sellRecord ) {
$this->sellRecords->removeElement( $sellRecord );
}
/**
* Set user.
*
* @param \AppBundle\Entity\User|null $user
*
* @return Festival
*/
public function setUser( \AppBundle\Entity\User $user = null ) {
$this->user = $user;
return $this;
}
/**
* Get user.
*
* @return \AppBundle\Entity\User|null
*/
public function getUser() {
return $this->user;
}
} }

View File

@ -41,6 +41,10 @@ class Festival {
*/ */
private $sellRecords; private $sellRecords;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="festivals")
*/
private $user;
/** /**
* Get id * Get id
@ -116,35 +120,33 @@ class Festival {
public function getSellRecords() { public function getSellRecords() {
return $this->sellRecords; return $this->sellRecords;
} }
/**
* Constructor
*/
public function __construct()
{
$this->sellRecords = new \Doctrine\Common\Collections\ArrayCollection();
}
/** /**
* Add sellRecord * Constructor
* */
* @param \AppBundle\Entity\SellRecord $sellRecord public function __construct() {
* $this->sellRecords = new \Doctrine\Common\Collections\ArrayCollection();
* @return Festival }
*/
public function addSellRecord(\AppBundle\Entity\SellRecord $sellRecord)
{
$this->sellRecords[] = $sellRecord;
return $this; /**
} * Add sellRecord
*
* @param \AppBundle\Entity\SellRecord $sellRecord
*
* @return Festival
*/
public function addSellRecord( \AppBundle\Entity\SellRecord $sellRecord ) {
$this->sellRecords[] = $sellRecord;
/** return $this;
* Remove sellRecord }
*
* @param \AppBundle\Entity\SellRecord $sellRecord /**
*/ * Remove sellRecord
public function removeSellRecord(\AppBundle\Entity\SellRecord $sellRecord) *
{ * @param \AppBundle\Entity\SellRecord $sellRecord
$this->sellRecords->removeElement($sellRecord); */
} public function removeSellRecord( \AppBundle\Entity\SellRecord $sellRecord ) {
$this->sellRecords->removeElement( $sellRecord );
}
} }

View File

@ -119,27 +119,25 @@ class ProductCategory {
$this->products->removeElement( $product ); $this->products->removeElement( $product );
} }
/** /**
* Add user * Add user
* *
* @param \AppBundle\Entity\User $user * @param \AppBundle\Entity\User $user
* *
* @return ProductCategory * @return ProductCategory
*/ */
public function addUser(\AppBundle\Entity\User $user) public function addUser( \AppBundle\Entity\User $user ) {
{ $this->users[] = $user;
$this->users[] = $user;
return $this; return $this;
} }
/** /**
* Remove user * Remove user
* *
* @param \AppBundle\Entity\User $user * @param \AppBundle\Entity\User $user
*/ */
public function removeUser(\AppBundle\Entity\User $user) public function removeUser( \AppBundle\Entity\User $user ) {
{ $this->users->removeElement( $user );
$this->users->removeElement($user); }
}
} }

View File

@ -22,14 +22,13 @@ class ProductSold {
*/ */
private $name; private $name;
/** /**
* @ORM\Column(type="string", length=256) * @ORM\Column(type="string", length=256)
*/ */
private $image; private $image;
/** /**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="products") * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="productsSold")
*/ */
private $user; private $user;
@ -92,4 +91,79 @@ class ProductSold {
public function getProduct() { public function getProduct() {
return $this->product; return $this->product;
} }
/**
* Get id.
*
* @return int
*/
public function getId() {
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return ProductSold
*/
public function setName( $name ) {
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* Set image.
*
* @param string $image
*
* @return ProductSold
*/
public function setImage( $image ) {
$this->image = $image;
return $this;
}
/**
* Get image.
*
* @return string
*/
public function getImage() {
return $this->image;
}
/**
* Set user.
*
* @param \AppBundle\Entity\User|null $user
*
* @return ProductSold
*/
public function setUser( \AppBundle\Entity\User $user = null ) {
$this->user = $user;
return $this;
}
/**
* Get user.
*
* @return \AppBundle\Entity\User|null
*/
public function getUser() {
return $this->user;
}
} }

View File

@ -39,6 +39,11 @@ class User extends BaseUser {
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="user") * @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="user")
*/ */
private $productsSold; private $productsSold;
/**
* variabilised products sold
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Festival", mappedBy="user")
*/
private $festivals;
/** /**
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\ProductCategory", inversedBy="users") * @ORM\ManyToMany(targetEntity="AppBundle\Entity\ProductCategory", inversedBy="users")
@ -165,85 +170,114 @@ class User extends BaseUser {
return $this->googleId; return $this->googleId;
} }
/**
* Add product
*
* @param \AppBundle\Entity\Product $product
*
* @return User
*/
public function addProduct( \AppBundle\Entity\Product $product ) {
$this->products[] = $product;
return $this;
}
/**
* Remove product
*
* @param \AppBundle\Entity\Product $product
*/
public function removeProduct( \AppBundle\Entity\Product $product ) {
$this->products->removeElement( $product );
}
/**
* Remove productsSold
*
* @param \AppBundle\Entity\ProductSold $productsSold
*/
public function removeProductsSold( \AppBundle\Entity\ProductSold $productsSold ) {
$this->productsSold->removeElement( $productsSold );
}
/**
* Add category
*
* @param \AppBundle\Entity\ProductCategory $category
*
* @return User
*/
public function addCategory( \AppBundle\Entity\ProductCategory $category ) {
$this->categories[] = $category;
return $this;
}
/**
* Remove category
*
* @param \AppBundle\Entity\ProductCategory $category
*/
public function removeCategory( \AppBundle\Entity\ProductCategory $category ) {
$this->categories->removeElement( $category );
}
/**
* Add sellRecord
*
* @param \AppBundle\Entity\SellRecord $sellRecord
*
* @return User
*/
public function addSellRecord( \AppBundle\Entity\SellRecord $sellRecord ) {
$this->sellRecords[] = $sellRecord;
return $this;
}
/**
* Remove sellRecord
*
* @param \AppBundle\Entity\SellRecord $sellRecord
*/
public function removeSellRecord( \AppBundle\Entity\SellRecord $sellRecord ) {
$this->sellRecords->removeElement( $sellRecord );
}
/** /**
* Add product * Add festival.
* *
* @param \AppBundle\Entity\Product $product * @param \AppBundle\Entity\Festival $festival
* *
* @return User * @return User
*/ */
public function addProduct(\AppBundle\Entity\Product $product) public function addFestival(\AppBundle\Entity\Festival $festival)
{ {
$this->products[] = $product; $this->festivals[] = $festival;
return $this; return $this;
} }
/** /**
* Remove product * Remove festival.
* *
* @param \AppBundle\Entity\Product $product * @param \AppBundle\Entity\Festival $festival
*
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
*/ */
public function removeProduct(\AppBundle\Entity\Product $product) public function removeFestival(\AppBundle\Entity\Festival $festival)
{ {
$this->products->removeElement($product); return $this->festivals->removeElement($festival);
} }
/** /**
* Remove productsSold * Get festivals.
* *
* @param \AppBundle\Entity\ProductSold $productsSold * @return \Doctrine\Common\Collections\Collection
*/ */
public function removeProductsSold(\AppBundle\Entity\ProductSold $productsSold) public function getFestivals()
{ {
$this->productsSold->removeElement($productsSold); return $this->festivals;
}
/**
* Add category
*
* @param \AppBundle\Entity\ProductCategory $category
*
* @return User
*/
public function addCategory(\AppBundle\Entity\ProductCategory $category)
{
$this->categories[] = $category;
return $this;
}
/**
* Remove category
*
* @param \AppBundle\Entity\ProductCategory $category
*/
public function removeCategory(\AppBundle\Entity\ProductCategory $category)
{
$this->categories->removeElement($category);
}
/**
* Add sellRecord
*
* @param \AppBundle\Entity\SellRecord $sellRecord
*
* @return User
*/
public function addSellRecord(\AppBundle\Entity\SellRecord $sellRecord)
{
$this->sellRecords[] = $sellRecord;
return $this;
}
/**
* Remove sellRecord
*
* @param \AppBundle\Entity\SellRecord $sellRecord
*/
public function removeSellRecord(\AppBundle\Entity\SellRecord $sellRecord)
{
$this->sellRecords->removeElement($sellRecord);
} }
} }

View File

@ -39,6 +39,11 @@ class User extends BaseUser {
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="user") * @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="user")
*/ */
private $productsSold; private $productsSold;
/**
* variabilised products sold
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Festival", mappedBy="user")
*/
private $festivals;
/** /**
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\ProductCategory", inversedBy="users") * @ORM\ManyToMany(targetEntity="AppBundle\Entity\ProductCategory", inversedBy="users")
@ -165,85 +170,78 @@ class User extends BaseUser {
return $this->googleId; return $this->googleId;
} }
/** /**
* Add product * Add product
* *
* @param \AppBundle\Entity\Product $product * @param \AppBundle\Entity\Product $product
* *
* @return User * @return User
*/ */
public function addProduct(\AppBundle\Entity\Product $product) public function addProduct( \AppBundle\Entity\Product $product ) {
{ $this->products[] = $product;
$this->products[] = $product;
return $this; return $this;
} }
/** /**
* Remove product * Remove product
* *
* @param \AppBundle\Entity\Product $product * @param \AppBundle\Entity\Product $product
*/ */
public function removeProduct(\AppBundle\Entity\Product $product) public function removeProduct( \AppBundle\Entity\Product $product ) {
{ $this->products->removeElement( $product );
$this->products->removeElement($product); }
}
/** /**
* Remove productsSold * Remove productsSold
* *
* @param \AppBundle\Entity\ProductSold $productsSold * @param \AppBundle\Entity\ProductSold $productsSold
*/ */
public function removeProductsSold(\AppBundle\Entity\ProductSold $productsSold) public function removeProductsSold( \AppBundle\Entity\ProductSold $productsSold ) {
{ $this->productsSold->removeElement( $productsSold );
$this->productsSold->removeElement($productsSold); }
}
/** /**
* Add category * Add category
* *
* @param \AppBundle\Entity\ProductCategory $category * @param \AppBundle\Entity\ProductCategory $category
* *
* @return User * @return User
*/ */
public function addCategory(\AppBundle\Entity\ProductCategory $category) public function addCategory( \AppBundle\Entity\ProductCategory $category ) {
{ $this->categories[] = $category;
$this->categories[] = $category;
return $this; return $this;
} }
/** /**
* Remove category * Remove category
* *
* @param \AppBundle\Entity\ProductCategory $category * @param \AppBundle\Entity\ProductCategory $category
*/ */
public function removeCategory(\AppBundle\Entity\ProductCategory $category) public function removeCategory( \AppBundle\Entity\ProductCategory $category ) {
{ $this->categories->removeElement( $category );
$this->categories->removeElement($category); }
}
/** /**
* Add sellRecord * Add sellRecord
* *
* @param \AppBundle\Entity\SellRecord $sellRecord * @param \AppBundle\Entity\SellRecord $sellRecord
* *
* @return User * @return User
*/ */
public function addSellRecord(\AppBundle\Entity\SellRecord $sellRecord) public function addSellRecord( \AppBundle\Entity\SellRecord $sellRecord ) {
{ $this->sellRecords[] = $sellRecord;
$this->sellRecords[] = $sellRecord;
return $this; return $this;
} }
/** /**
* Remove sellRecord * Remove sellRecord
* *
* @param \AppBundle\Entity\SellRecord $sellRecord * @param \AppBundle\Entity\SellRecord $sellRecord
*/ */
public function removeSellRecord(\AppBundle\Entity\SellRecord $sellRecord) public function removeSellRecord( \AppBundle\Entity\SellRecord $sellRecord ) {
{ $this->sellRecords->removeElement( $sellRecord );
$this->sellRecords->removeElement($sellRecord); }
}
} }

View File

@ -6,31 +6,30 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class FestivalType extends AbstractType class FestivalType extends AbstractType {
{ /**
/** * {@inheritdoc}
* {@inheritdoc} */
*/ public function buildForm( FormBuilderInterface $builder, array $options ) {
public function buildForm(FormBuilderInterface $builder, array $options) $builder->add( 'name' )// ->add('dateCreation')
{ ;
$builder->add('name')->add('dateCreation'); }
}/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Festival'
));
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getBlockPrefix() public function configureOptions( OptionsResolver $resolver ) {
{ $resolver->setDefaults( [
return 'appbundle_festival'; 'data_class' => 'AppBundle\Entity\Festival',
} ] );
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix() {
return 'appbundle_festival';
}
} }

View File

@ -13,7 +13,9 @@ class ProductCategoryType extends AbstractType
*/ */
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->add('name')->add('users'); $builder->add('name')
// ->add('users')
;
}/** }/**
* {@inheritdoc} * {@inheritdoc}
*/ */