remove entities for testing purpose - clean code

fix #259
This commit is contained in:
Julien Fastré 2015-01-22 09:50:53 +01:00
parent 4d4a3116a0
commit 3707b08aee
44 changed files with 0 additions and 2462 deletions

View File

@ -1,224 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Chill\CustomFieldsBundle\Entity\Adress;
use Chill\CustomFieldsBundle\Form\AdressType;
/**
* Adress controller.
*
*/
class AdressController extends Controller
{
/**
* Lists all Adress entities.
*
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('ChillCustomFieldsBundle:Adress')->findAll();
return $this->render('ChillCustomFieldsBundle:Adress:index.html.twig', array(
'entities' => $entities,
));
}
/**
* Creates a new Adress entity.
*
*/
public function createAction(Request $request)
{
$entity = new Adress();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('adress_show', array('id' => $entity->getId())));
}
return $this->render('ChillCustomFieldsBundle:Adress:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
}
/**
* Creates a form to create a Adress entity.
*
* @param Adress $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCreateForm(Adress $entity)
{
$form = $this->createForm(new AdressType(), $entity, array(
'action' => $this->generateUrl('adress_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
}
/**
* Displays a form to create a new Adress entity.
*
*/
public function newAction()
{
$entity = new Adress();
$form = $this->createCreateForm($entity);
return $this->render('ChillCustomFieldsBundle:Adress:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
}
/**
* Finds and displays a Adress entity.
*
*/
public function showAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:Adress')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Adress entity.');
}
$deleteForm = $this->createDeleteForm($id);
return $this->render('ChillCustomFieldsBundle:Adress:show.html.twig', array(
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
));
}
/**
* Displays a form to edit an existing Adress entity.
*
*/
public function editAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:Adress')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Adress entity.');
}
$editForm = $this->createEditForm($entity);
$deleteForm = $this->createDeleteForm($id);
return $this->render('ChillCustomFieldsBundle:Adress:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Creates a form to edit a Adress entity.
*
* @param Adress $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createEditForm(Adress $entity)
{
$form = $this->createForm(new AdressType(), $entity, array(
'action' => $this->generateUrl('adress_update', array('id' => $entity->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
}
/**
* Edits an existing Adress entity.
*
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:Adress')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Adress entity.');
}
$deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('adress_edit', array('id' => $id)));
}
return $this->render('ChillCustomFieldsBundle:Adress:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Deletes a Adress entity.
*
*/
public function deleteAction(Request $request, $id)
{
$form = $this->createDeleteForm($id);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:Adress')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Adress entity.');
}
$em->remove($entity);
$em->flush();
}
return $this->redirect($this->generateUrl('adress'));
}
/**
* Creates a form to delete a Adress entity by id.
*
* @param mixed $id The entity id
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm($id)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('adress_delete', array('id' => $id)))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()
;
}
}

View File

@ -1,226 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Chill\CustomFieldsBundle\Entity\BlopEntity2;
use Chill\CustomFieldsBundle\Form\BlopEntity2Type;
/**
* BlopEntity2 controller.
*
*/
class BlopEntity2Controller extends Controller
{
/**
* Lists all BlopEntity2 entities.
*
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('ChillCustomFieldsBundle:BlopEntity2')->findAll();
return $this->render('ChillCustomFieldsBundle:BlopEntity2:index.html.twig', array(
'entities' => $entities,
));
}
/**
* Creates a new BlopEntity2 entity.
*
*/
public function createAction(Request $request)
{
$entity = new BlopEntity2();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('blopentity2_show', array('id' => $entity->getId())));
}
return $this->render('ChillCustomFieldsBundle:BlopEntity2:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
}
/**
* Creates a form to create a BlopEntity2 entity.
*
* @param BlopEntity2 $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCreateForm(BlopEntity2 $entity)
{
$form = $this->createForm(new BlopEntity2Type(), $entity, array(
'action' => $this->generateUrl('blopentity2_create'),
'method' => 'POST',
'em' => $this->getDoctrine()->getManager(),
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
}
/**
* Displays a form to create a new BlopEntity2 entity.
*
*/
public function newAction()
{
$entity = new BlopEntity2();
$form = $this->createCreateForm($entity);
return $this->render('ChillCustomFieldsBundle:BlopEntity2:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
}
/**
* Finds and displays a BlopEntity2 entity.
*
*/
public function showAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:BlopEntity2')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find BlopEntity2 entity.');
}
$deleteForm = $this->createDeleteForm($id);
return $this->render('ChillCustomFieldsBundle:BlopEntity2:show.html.twig', array(
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
));
}
/**
* Displays a form to edit an existing BlopEntity2 entity.
*
*/
public function editAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:BlopEntity2')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find BlopEntity2 entity.');
}
$editForm = $this->createEditForm($entity);
$deleteForm = $this->createDeleteForm($id);
return $this->render('ChillCustomFieldsBundle:BlopEntity2:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Creates a form to edit a BlopEntity2 entity.
*
* @param BlopEntity2 $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createEditForm(BlopEntity2 $entity)
{
$form = $this->createForm(new BlopEntity2Type(), $entity, array(
'action' => $this->generateUrl('blopentity2_update', array('id' => $entity->getId())),
'method' => 'PUT',
'em' => $this->getDoctrine()->getManager(),
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
}
/**
* Edits an existing BlopEntity2 entity.
*
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:BlopEntity2')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find BlopEntity2 entity.');
}
$deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('blopentity2_edit', array('id' => $id)));
}
return $this->render('ChillCustomFieldsBundle:BlopEntity2:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Deletes a BlopEntity2 entity.
*
*/
public function deleteAction(Request $request, $id)
{
$form = $this->createDeleteForm($id);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:BlopEntity2')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find BlopEntity2 entity.');
}
$em->remove($entity);
$em->flush();
}
return $this->redirect($this->generateUrl('blopentity2'));
}
/**
* Creates a form to delete a BlopEntity2 entity by id.
*
* @param mixed $id The entity id
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm($id)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('blopentity2_delete', array('id' => $id)))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()
;
}
}

View File

@ -1,291 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Chill\CustomFieldsBundle\Entity\BlopEntity;
use Chill\CustomFieldsBundle\Form\BlopEntityType;
use Chill\CustomFieldsBundle\Form\AdressType;
/**
* BlopEntity controller.
*
*/
class BlopEntityController extends Controller
{
public function addNewManyToOneAction($id, $key)
{
$em = $this->getDoctrine()->getManager();
$customFields = $em->getRepository('ChillCustomFieldsBundle:CustomField')
->findAll();
$customFieldsLablels = array_map(
function($e) { return $e->getLabel(); },
$customFields);
$customFieldsByLabel = array_combine($customFieldsLablels, $customFields);
if (array_key_exists($key,$customFieldsByLabel)) {
$customFieldConfig = $customFieldsByLabel[$key];
if($customFieldConfig->getType() === 'OneToMany(Adress)') {
$manyToOneEntity = new AdressType();
$form = $this->createCreateForm($manyToOneEntity);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($manyToOneEntity);
$em->flush();
$blopEntity = $this->om
->getRepository('ChillCustomFieldsBundle:CustomField')
->findOneById($id);
$blopEntityCustomFieldArray = json_decode($blopEntity->getCustomField());
$blopEntityCustomFieldArray[$key][] = $manyToOneEntity->getId();
}
} else {
// PAS MANY TO ONE
throw new Exception("Error Processing Request", 1);
}
} else {
// PAS RENSEIGNE COMME CF
throw new Exception("Error Processing Request", 1);
}
}
/**
* Lists all BlopEntity entities.
*
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('ChillCustomFieldsBundle:BlopEntity')->findAll();
return $this->render('ChillCustomFieldsBundle:BlopEntity:index.html.twig', array(
'entities' => $entities,
));
}
public function cfSetAction($id,$key,$value)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:BlopEntity')->find($id);
echo $entity->cfSet($key,$value);
var_dump($entity->getCustomField());
$em->persist($entity);
$em->flush();
return null;//$entity->cfSet($key,$value);
}
public function cfGetAction($id,$key)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:BlopEntity')->find($id);
echo $entity->cfGet($key);
return null;//return $entity->cfGet($key);
}
/**
* Creates a new BlopEntity entity.
*
*/
public function createAction(Request $request)
{
$entity = new BlopEntity();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('blopentity_show', array('id' => $entity->getId())));
}
return $this->render('ChillCustomFieldsBundle:BlopEntity:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
}
/**
* Creates a form to create a BlopEntity entity.
*
* @param BlopEntity $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCreateForm(BlopEntity $entity)
{
$form = $this->createForm(new BlopEntityType(), $entity, array(
'action' => $this->generateUrl('blopentity_create'),
'method' => 'POST',
'em' => $this->getDoctrine()->getManager(),
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
}
/**
* Displays a form to create a new BlopEntity entity.
*
*/
public function newAction()
{
$entity = new BlopEntity();
$form = $this->createCreateForm($entity);
return $this->render('ChillCustomFieldsBundle:BlopEntity:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
}
/**
* Finds and displays a BlopEntity entity.
*
*/
public function showAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:BlopEntity')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find BlopEntity entity.');
}
$deleteForm = $this->createDeleteForm($id);
return $this->render('ChillCustomFieldsBundle:BlopEntity:show.html.twig', array(
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
));
}
/**
* Displays a form to edit an existing BlopEntity entity.
*
*/
public function editAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:BlopEntity')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find BlopEntity entity.');
}
$editForm = $this->createEditForm($entity);
$deleteForm = $this->createDeleteForm($id);
return $this->render('ChillCustomFieldsBundle:BlopEntity:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Creates a form to edit a BlopEntity entity.
*
* @param BlopEntity $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createEditForm(BlopEntity $entity)
{
$form = $this->createForm(new BlopEntityType(), $entity, array(
'action' => $this->generateUrl('blopentity_update', array('id' => $entity->getId())),
'method' => 'PUT',
'em' => $this->getDoctrine()->getManager(),
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
}
/**
* Edits an existing BlopEntity entity.
*
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:BlopEntity')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find BlopEntity entity.');
}
$deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('blopentity_edit', array('id' => $id)));
}
return $this->render('ChillCustomFieldsBundle:BlopEntity:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Deletes a BlopEntity entity.
*
*/
public function deleteAction(Request $request, $id)
{
$form = $this->createDeleteForm($id);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillCustomFieldsBundle:BlopEntity')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find BlopEntity entity.');
}
$em->remove($entity);
$em->flush();
}
return $this->redirect($this->generateUrl('blopentity'));
}
/**
* Creates a form to delete a BlopEntity entity by id.
*
* @param mixed $id The entity id
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm($id)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('blopentity_delete', array('id' => $id)))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()
;
}
}

View File

@ -1,91 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\CustomFields;
use Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface;
use Chill\CustomFieldsBundle\Entity\CustomField;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\EntityManagerInterface;
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer;
use Chill\CustomFieldsBundle\Form\AdressType;
/**
* Description of CustomFieldAddress
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class CustomFieldAddress implements CustomFieldInterface
{
/**
*
* @var EntityManagerInterface
*/
public $om;
public function __construct(EntityManagerInterface $om)
{
$this->om = $om;
}
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
{
$builder->add(
$builder->create('address', 'entity', array(
'class' => 'ChillCustomFieldsBundle:Adress',
'multiple' => true,
'expanded' => true
)
)->addModelTransformer(new CustomFieldDataTransformer(
$this,
$customField)
)
);
}
public function getName()
{
return 'CF address';
}
public function render($value, CustomField $customField)
{
}
public function buildOptionsForm(FormBuilderInterface $builder)
{
return null;
}
public function deserialize($serialized, CustomField $customField)
{
// if ($serialized === NULL) {
// return null;
// }
//
// return $this->om->getRepository('ChillCustomFieldsBundle:Adress')
// ->find($serialized);
return $this->om->getRepository('ChillCustomFieldsBundle:Adress')
->findBy(array('id' => $serialized));
}
/**
*
* @param \Chill\CustomFieldsBundle\Entity\Adress $value
* @param CustomField $customField
* @return type
*/
public function serialize($value, CustomField $customField)
{
$arrayId = array();
foreach($value as $address) {
$arrayId[] = $address->getId();
}
return $arrayId;
}
}

View File

@ -1,59 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Entity;
/**
* Adress
*/
class Adress
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $data;
public function __toString()
{
return $this->data . '(id:' .$this->id .')';
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set data
*
* @param string $data
*
* @return Adress
*/
public function setData($data)
{
$this->data = $data;
return $this;
}
/**
* Get data
*
* @return string
*/
public function getData()
{
return $this->data;
}
}

View File

@ -1,161 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Entity;
/**
* BlopEntity
*/
class BlopEntity
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $field1;
/**
* @var string
*/
private $field2;
/**
* @var array
*/
private $customField = array();
private $adress;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
public function setAdress($a)
{
$this->adress = $a;
return $this;
}
/**
* Get field1
*
* @return string
*/
public function getAdress()
{
return $this->adress;
}
/**
* Set field1
*
* @param string $field1
*
* @return BlopEntity
*/
public function setField1($field1)
{
$this->field1 = $field1;
return $this;
}
/**
* Get field1
*
* @return string
*/
public function getField1()
{
return $this->field1;
}
/**
* Set field2
*
* @param string $field2
*
* @return BlopEntity
*/
public function setField2($field2)
{
$this->field2 = $field2;
return $this;
}
/**
* Get field2
*
* @return string
*/
public function getField2()
{
return $this->field2;
}
/**
* Set customField
*
* @param array $customField
*
* @return BlopEntity
*/
public function setCustomField(array $customField)
{
$this->customField = $customField;
return $this;
}
/**
* Get customField
*
* @return array
*/
public function getCustomField()
{
return $this->customField;
}
public function cfGet($key)
{
echo "<br> -1- <br>";
echo gettype($this->customField);
echo "<br> -2- <br>";
echo $this->customField;
echo "<br> -3- <br>";
var_dump(json_decode($this->customField));
echo "<br> -4- <br>";
echo json_last_error_msg();
$customFieldArray = json_decode($this->customField, true);
if(array_key_exists($key, $customFieldArray)) {
return $customFieldArray[$key];
} else {
return null;
}
}
public function cfSet($key, $value)
{
echo "-";
$customFieldArray = json_decode($this->customField, true);
$customFieldArray[$key] = $value;
$this->setCustomField(json_encode($customFieldArray));
var_dump($customFieldArray);
}
}

View File

@ -1,247 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Entity;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PreFlushEventArgs;
use Doctrine\Common\Collections\ArrayCollection;
use Chill\CustomFieldsBundle\Entity\Adress;
// ATTENTION QD NOUVEL OBJ cree sans appel a doctrine
// on n'a pas la config de custom fields
// ET DONC ON NE SAIT PAS QUELS VARIABLES SONT VIA __GET
// ET __SET SONT DECRITES PAR CUSTOM FIELDS
// IDEE : Travailler avec Lifecycle
// set et get pour JSON Field
// - dans un tableau special
// postLoad (après que l'élément sort du EM) :
// - récupération des customs fields (ok!)
// - json -> obj dans des choses qui existent deja
// preFlush avant mise a jour de la db
// - met a jour les donnees liees au json et le json
// perPersist idem mais pour le persist
/**
* BlopEntity2
*/
class BlopEntity2
{
/**
* @var integer
*/
private $id;
/**
* @var array
*/
private $customFieldData;
private $customFieldDataArray = array(); // customField apres json_decode
private $customFieldDataUnfolded = array(); // mise des entity de customFieldDataArray
private $customFieldConfigs = array();
private $customFieldConfigsLoaded = false;
// CHARGE DE LA DB LA CONFIG DES CUSTOM FIELDS
public function loadCustomFieldConfig(LifecycleEventArgs $args)
{
$em = $args->getObjectManager();
$customFields = $em
->getRepository('ChillCustomFieldsBundle:CustomField')
->findAll();
$customFieldsLablels = array_map(
function($e) { return $e->getLabel(); },
$customFields);
$this->customFieldConfigs = array_combine($customFieldsLablels, $customFields);
$this->customFieldConfigsLoaded = true;
}
// A PARTIR DU JSON CREE LES OBJETS (MIS DANS customFieldDataUnfolded)
public function unfoldCustomFieldData(LifecycleEventArgs $args)
{
$em = $args->getObjectManager();
$customFieldDataArray = json_decode($this->customFieldData,true);
$customFieldDataUnfolded = array();
foreach ($this->customFieldConfigs as $key => $cfConfig) {
$type = $cfConfig->getType();
if(strpos($type,'ManyToMany') === 0) {
$fieldUnfolded = new ArrayCollection();
if(array_key_exists($key, $customFieldDataArray)) {
$entityClass = substr($type, 11, -1);
foreach ($customFieldDataArray[$key] as $idEntity) {
$fieldUnfolded->add($em
->getRepository('ChillCustomFieldsBundle:' . $entityClass)
->findOneById($idEntity));
}
}
$customFieldDataUnfolded[$key] = $fieldUnfolded;
} else if(strpos($type,'ManyToOne') === 0) {
$entityClass = 'Adress'; // substr($type,10,-1);
if(array_key_exists($key, $customFieldDataArray)) {
$customFieldDataUnfolded[$key] = $em
->getRepository('ChillCustomFieldsBundle:' . $entityClass)
->findOneById($customFieldDataArray[$key]);
} else {
// TODO : doit tjs avoir un id
$em
->getRepository('ChillCustomFieldsBundle:' . $entityClass)
->findOneById(1);
}
}
else if ($type === 'text') {
if(array_key_exists($key, $customFieldDataArray)) {
$customFieldDataUnfolded[$key] = $customFieldDataArray[$key];
} else {
$customFieldDataUnfolded[$key] = '';
}
}
}
$this->customFieldDataUnfolded = $customFieldDataUnfolded;
}
// AVANT PERSIST LES ELEMENTS QUI N'ONT PAS D'ID DOIVENT EN AVOIR UN (OM->PERSIST(OBJ))
// PUIS PASSAGE DES OBJETS (SE TROUVANT DANS customFieldDataUnfolded) VERS
// LE JSON (SE TROUVANT DANS customFieldData)
public function prePersist(LifecycleEventArgs $args)
{
$em = $args->getObjectManager();
$this->loadCustomFieldConfig($args);
foreach ($this->customFieldDataUnfolded as $key => $unfoldedData) {
$type = $this->customFieldConfigs[$key]->getType();
if(strpos($type,'ManyToMany') === 0) {
foreach ($this->customFieldDataUnfolded[$key] as $entity) {
if(! $entity->getId()) {
$em->persist($entity);
}
}
} else if(strpos($type,'ManyToOne') === 0) {
if(! $this->customFieldDataUnfolded[$key]->getId()) {
$em->persist($this->customFieldDataUnfolded[$key]);
}
}
}
$this->customFieldDataUnfoldedToCustomField();
}
// PUIS PASSAGE DES OBJETS (SE TROUVANT DANS customFieldDataUnfolded) VERS
// LE JSON (SE TROUVANT DANS customFieldData)
public function preFlush(PreFlushEventArgs $args)
{
$this->customFieldDataUnfoldedToCustomField();
}
// PUIS PASSAGE DES OBJETS (SE TROUVANT DANS customFieldDataUnfolded) VERS
// LE JSON (SE TROUVANT DANS customFieldData)
public function customFieldDataUnfoldedToCustomField()
{
// MISE A JOUR DE customFieldDataArray
foreach ($this->customFieldConfigs as $key => $cfConfig) {
$type = $cfConfig->getType();
if(strpos($type,'ManyToMany') === 0) {
$arrayMapRet = array();
foreach ($this->customFieldDataUnfolded[$key] as $entity) {
$arrayMapRet[] = $entity->getId();
}
$this->customFieldDataArray[$key] = $arrayMapRet; // array_map(function($e) { $e->getId(); }, $this->customFieldDataUnfolded[$key]);
} else if(strpos($type,'ManyToOne') === 0) {
if(array_key_exists($key, $this->customFieldDataUnfolded)) {
$this->customFieldDataArray[$key] = $this->customFieldDataUnfolded[$key]->getId();
} else {
// normalement $this->customFieldDataArray[$key] ne doit pas exister
if(array_key_exists($key, $this->customFieldDataArray)) {
throw new Exception("Error Processing Request", 1);
}
//retirer de $this->customFieldDataArray[$key]
}
} else if ($type === 'text') {
$this->customFieldDataArray[$key] = $this->customFieldDataUnfolded[$key];
}
}
// MISE A JOUR DE CustomFieldData
$this->setCustomFieldData(json_encode($this->customFieldDataArray));
}
public function __set($fieldName, $value) {
$setMethodName = 'set' . ucfirst($fieldName);
if(method_exists($this, $setMethodName)) {
return $this->{$setMethodName}($value);
}
if(array_key_exists($fieldName, $this->customFieldConfigs)) {
$this->customFieldDataUnfolded[$fieldName] = $value;
} else if (!$this->customFieldConfigsLoaded) { // nouvel object pas eu d'appel doctrine avant
$this->customFieldDataUnfolded[$fieldName] = $value;
} else {
throw new Exception("Error Processing Request", 1);
}
}
public function __get($fieldName) {
$getMethodName = 'get' . ucfirst($fieldName);
if(method_exists($this, $getMethodName)) {
return $this->{$getMethodName}();
}
if(array_key_exists($fieldName, $this->customFieldDataUnfolded)) {
return $this->customFieldDataUnfolded[$fieldName];
} else if (!$this->customFieldConfigsLoaded) { // nouvel object pas eu d'appel doctrine avant
return null;
} else if(array_key_exists($fieldName, $this->customFieldConfigs)) { // pas init
return null;
} else {
throw new Exception("Error Processing Request", 1);
}
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set customField
*
* @param array $customField
*
* @return BlopEntity2
*/
public function setCustomFieldData($customFieldData)
{
$this->customFieldData = $customFieldData;
return $this;
}
/**
* Get customField
*
* @return array
*/
public function getCustomFieldData()
{
return $this->customFieldData;
}
}

View File

@ -1,14 +0,0 @@
Chill\CustomFieldsBundle\Entity\Adress:
type: entity
table: null
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
data:
type: string
length: 255
lifecycleCallbacks: { }

View File

@ -1,23 +0,0 @@
Chill\CustomFieldsBundle\Entity\BlopEntity:
type: entity
table: blop_entity
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
field1:
type: string
length: 255
field2:
type: string
length: 255
customField:
type: json_array
manyToOne:
adress:
targetEntity: Chill\CustomFieldsBundle\Entity\Adress
cascade: [persist]
lifecycleCallbacks: { }

View File

@ -1,16 +0,0 @@
Chill\CustomFieldsBundle\Entity\BlopEntity2:
type: entity
table: null
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
customFieldData:
type: json_array
lifecycleCallbacks:
postLoad: [ loadCustomFieldConfig, unfoldCustomFieldData ]
preFlush: [ preFlush ]
prePersist: [ prePersist ]

View File

@ -2,22 +2,10 @@ chill_customfields_customfieldsgroup:
resource: "@ChillCustomFieldsBundle/Resources/config/routing/customfieldsgroup.yml"
prefix: /
chill_customfields_blopentity2:
resource: "@ChillCustomFieldsBundle/Resources/config/routing/blopentity2.yml"
prefix: /blopentity2
chill_customfields_adress:
resource: "@ChillCustomFieldsBundle/Resources/config/routing/adress.yml"
prefix: /adress
chill_customfields_customfield:
resource: "@ChillCustomFieldsBundle/Resources/config/routing/customfield.yml"
prefix: /
chill_customfields_blopentity:
resource: "@ChillCustomFieldsBundle/Resources/config/routing/blopentity.yml"
prefix: /
chill_customfields_customfieldsdefaultgroup:
resource: "@ChillCustomFieldsBundle/Resources/config/routing/customfieldsdefaultgroup.yml"
prefix: /

View File

@ -1,30 +0,0 @@
adress:
path: /
defaults: { _controller: "ChillCustomFieldsBundle:Adress:index" }
adress_show:
path: /{id}/show
defaults: { _controller: "ChillCustomFieldsBundle:Adress:show" }
adress_new:
path: /new
defaults: { _controller: "ChillCustomFieldsBundle:Adress:new" }
adress_create:
path: /create
defaults: { _controller: "ChillCustomFieldsBundle:Adress:create" }
requirements: { _method: post }
adress_edit:
path: /{id}/edit
defaults: { _controller: "ChillCustomFieldsBundle:Adress:edit" }
adress_update:
path: /{id}/update
defaults: { _controller: "ChillCustomFieldsBundle:Adress:update" }
requirements: { _method: post|put }
adress_delete:
path: /{id}/delete
defaults: { _controller: "ChillCustomFieldsBundle:Adress:delete" }
requirements: { _method: post|delete }

View File

@ -1,42 +0,0 @@
blopentity:
path: /
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity:index" }
blopentity_show:
path: /{id}/show
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity:show" }
blopentity_new:
path: /new
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity:new" }
blopentity_create:
path: /create
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity:create" }
requirements: { _method: post }
blopentity_edit:
path: /{id}/edit
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity:edit" }
blopentity_update:
path: /{id}/update
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity:update" }
requirements: { _method: post|put }
blopentity_delete:
path: /{id}/delete
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity:delete" }
requirements: { _method: post|delete }
blopentity_cfget:
path: /{id}/cfget/{key}
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity:cfGet" }
blopentity_cfset:
path: /{id}/cfset/{key}/{value}
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity:cfSet" }
blopentity_addmany_to_one:
path: /{id}/add/custom/field/{key}
defaults: {_controller: "ChillCustomFieldsBundle:BlopEntity:addNewManyToOne"}

View File

@ -1,30 +0,0 @@
blopentity2:
path: /
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity2:index" }
blopentity2_show:
path: /{id}/show
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity2:show" }
blopentity2_new:
path: /new
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity2:new" }
blopentity2_create:
path: /create
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity2:create" }
requirements: { _method: post }
blopentity2_edit:
path: /{id}/edit
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity2:edit" }
blopentity2_update:
path: /{id}/update
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity2:update" }
requirements: { _method: post|put }
blopentity2_delete:
path: /{id}/delete
defaults: { _controller: "ChillCustomFieldsBundle:BlopEntity2:delete" }
requirements: { _method: post|delete }

View File

@ -1,16 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>Adress edit</h1>
{{ form(edit_form) }}
<ul class="record_actions">
<li>
<a href="{{ path('adress') }}">
Back to the list
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,41 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>Adress list</h1>
<table class="records_list">
<thead>
<tr>
<th>Id</th>
<th>Data</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td><a href="{{ path('adress_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
<td>{{ entity.data }}</td>
<td>
<ul>
<li>
<a href="{{ path('adress_show', { 'id': entity.id }) }}">show</a>
</li>
<li>
<a href="{{ path('adress_edit', { 'id': entity.id }) }}">edit</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('adress_new') }}">
Create a new entry
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,15 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>Adress creation</h1>
{{ form(form) }}
<ul class="record_actions">
<li>
<a href="{{ path('adress') }}">
Back to the list
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,32 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>Adress</h1>
<table class="record_properties">
<tbody>
<tr>
<th>Id</th>
<td>{{ entity.id }}</td>
</tr>
<tr>
<th>Data</th>
<td>{{ entity.data }}</td>
</tr>
</tbody>
</table>
<ul class="record_actions">
<li>
<a href="{{ path('adress') }}">
Back to the list
</a>
</li>
<li>
<a href="{{ path('adress_edit', { 'id': entity.id }) }}">
Edit
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,22 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>BlopEntity edit</h1>
{{ form_start(edit_form) }}
{{ form_row(edit_form.customField) }}
{{ form_rest(edit_form) }}
{{ form_end(edit_form) }}
<ul class="record_actions">
<li>
<a href="{{ path('blopentity') }}">
Back to the list
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,45 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>BlopEntity list</h1>
<table class="records_list">
<thead>
<tr>
<th>Id</th>
<th>Field1</th>
<th>Field2</th>
<th>Customfield</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td><a href="{{ path('blopentity_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
<td>{{ entity.field1 }}</td>
<td>{{ entity.field2 }}</td>
<td>{{ dump(entity.customField) }}</td>
<td>
<ul>
<li>
<a href="{{ path('blopentity_show', { 'id': entity.id }) }}">show</a>
</li>
<li>
<a href="{{ path('blopentity_edit', { 'id': entity.id }) }}">edit</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('blopentity_new') }}">
Create a new entry
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,15 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>BlopEntity creation</h1>
{{ form(form) }}
<ul class="record_actions">
<li>
<a href="{{ path('blopentity') }}">
Back to the list
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,40 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>BlopEntity</h1>
<table class="record_properties">
<tbody>
<tr>
<th>Id</th>
<td>{{ entity.id }}</td>
</tr>
<tr>
<th>Field1</th>
<td>{{ entity.field1 }}</td>
</tr>
<tr>
<th>Field2</th>
<td>{{ entity.field2 }}</td>
</tr>
<tr>
<th>Customfield</th>
<td>{{ dump(entity.customField) }}</td>
</tr>
</tbody>
</table>
<ul class="record_actions">
<li>
<a href="{{ path('blopentity') }}">
Back to the list
</a>
</li>
<li>
<a href="{{ path('blopentity_edit', { 'id': entity.id }) }}">
Edit
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,16 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>BlopEntity2 edit</h1>
{{ form(edit_form) }}
<ul class="record_actions">
<li>
<a href="{{ path('blopentity2') }}">
Back to the list
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,41 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>BlopEntity2 list</h1>
<table class="records_list">
<thead>
<tr>
<th>Id</th>
<th>CustomfieldData</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td><a href="{{ path('blopentity2_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
<td>{{ entity.CustomfieldData }}</td>
<td>
<ul>
<li>
<a href="{{ path('blopentity2_show', { 'id': entity.id }) }}">show</a>
</li>
<li>
<a href="{{ path('blopentity2_edit', { 'id': entity.id }) }}">edit</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('blopentity2_new') }}">
Create a new entry
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,15 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>BlopEntity2 creation</h1>
{{ form(form) }}
<ul class="record_actions">
<li>
<a href="{{ path('blopentity2') }}">
Back to the list
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,32 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>BlopEntity2</h1>
<table class="record_properties">
<tbody>
<tr>
<th>Id</th>
<td>{{ entity.id }}</td>
</tr>
<tr>
<th>CustomfieldData</th>
<td>{{ entity.customFieldData }}</td>
</tr>
</tbody>
</table>
<ul class="record_actions">
<li>
<a href="{{ path('blopentity2') }}">
Back to the list
</a>
</li>
<li>
<a href="{{ path('blopentity2_edit', { 'id': entity.id }) }}">
Edit
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,16 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>Entity edit</h1>
{{ form(edit_form) }}
<ul class="record_actions">
<li>
<a href="{{ path('entity') }}">
Back to the list
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,45 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>Entity list</h1>
<table class="records_list">
<thead>
<tr>
<th>Id</th>
<th>Field1</th>
<th>Field2</th>
<th>Customfields</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td><a href="{{ path('entity_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
<td>{{ entity.field1 }}</td>
<td>{{ entity.field2 }}</td>
<td>{{ entity.customFields }}</td>
<td>
<ul>
<li>
<a href="{{ path('entity_show', { 'id': entity.id }) }}">show</a>
</li>
<li>
<a href="{{ path('entity_edit', { 'id': entity.id }) }}">edit</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('entity_new') }}">
Create a new entry
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,15 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>Entity creation</h1>
{{ form(form) }}
<ul class="record_actions">
<li>
<a href="{{ path('entity') }}">
Back to the list
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,40 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>Entity</h1>
<table class="record_properties">
<tbody>
<tr>
<th>Id</th>
<td>{{ entity.id }}</td>
</tr>
<tr>
<th>Field1</th>
<td>{{ entity.field1 }}</td>
</tr>
<tr>
<th>Field2</th>
<td>{{ entity.field2 }}</td>
</tr>
<tr>
<th>Customfields</th>
<td>{{ entity.customFields }}</td>
</tr>
</tbody>
</table>
<ul class="record_actions">
<li>
<a href="{{ path('entity') }}">
Back to the list
</a>
</li>
<li>
<a href="{{ path('entity_edit', { 'id': entity.id }) }}">
Edit
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,16 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>TestEntity edit</h1>
{{ form(edit_form) }}
<ul class="record_actions">
<li>
<a href="{{ path('testentity') }}">
Back to the list
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,45 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>TestEntity list</h1>
<table class="records_list">
<thead>
<tr>
<th>Id</th>
<th>Field1</th>
<th>Field2</th>
<th>Customfields</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td><a href="{{ path('testentity_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
<td>{{ entity.field1 }}</td>
<td>{{ entity.field2 }}</td>
<td>{{ entity.customFields }}</td>
<td>
<ul>
<li>
<a href="{{ path('testentity_show', { 'id': entity.id }) }}">show</a>
</li>
<li>
<a href="{{ path('testentity_edit', { 'id': entity.id }) }}">edit</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('testentity_new') }}">
Create a new entry
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,15 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>TestEntity creation</h1>
{{ form(form) }}
<ul class="record_actions">
<li>
<a href="{{ path('testentity') }}">
Back to the list
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,40 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>TestEntity</h1>
<table class="record_properties">
<tbody>
<tr>
<th>Id</th>
<td>{{ entity.id }}</td>
</tr>
<tr>
<th>Field1</th>
<td>{{ entity.field1 }}</td>
</tr>
<tr>
<th>Field2</th>
<td>{{ entity.field2 }}</td>
</tr>
<tr>
<th>Customfields</th>
<td>{{ entity.customFields }}</td>
</tr>
</tbody>
</table>
<ul class="record_actions">
<li>
<a href="{{ path('testentity') }}">
Back to the list
</a>
</li>
<li>
<a href="{{ path('testentity_edit', { 'id': entity.id }) }}">
Edit
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,16 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>TestExtraColumn edit</h1>
{{ form(edit_form) }}
<ul class="record_actions">
<li>
<a href="{{ path('testextracolumn') }}">
Back to the list
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,41 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>TestExtraColumn list</h1>
<table class="records_list">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td><a href="{{ path('testextracolumn_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
<td>{{ entity.name }}</td>
<td>
<ul>
<li>
<a href="{{ path('testextracolumn_show', { 'id': entity.id }) }}">show</a>
</li>
<li>
<a href="{{ path('testextracolumn_edit', { 'id': entity.id }) }}">edit</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('testextracolumn_new') }}">
Create a new entry
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,15 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>TestExtraColumn creation</h1>
{{ form(form) }}
<ul class="record_actions">
<li>
<a href="{{ path('testextracolumn') }}">
Back to the list
</a>
</li>
</ul>
{% endblock %}

View File

@ -1,32 +0,0 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>TestExtraColumn</h1>
<table class="record_properties">
<tbody>
<tr>
<th>Id</th>
<td>{{ entity.id }}</td>
</tr>
<tr>
<th>Name</th>
<td>{{ entity.name }}</td>
</tr>
</tbody>
</table>
<ul class="record_actions">
<li>
<a href="{{ path('testextracolumn') }}">
Back to the list
</a>
</li>
<li>
<a href="{{ path('testextracolumn_edit', { 'id': entity.id }) }}">
Edit
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@ -1,55 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class AdressControllerTest 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', '/adress/');
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /adress/");
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
// Fill in the form and submit it
$form = $crawler->selectButton('Create')->form(array(
'cl_customfieldsbundle_adress[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(
'cl_customfieldsbundle_adress[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());
}
*/
}

View File

@ -1,55 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class BlopEntity2ControllerTest 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', '/blopentity2/');
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /blopentity2/");
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
// Fill in the form and submit it
$form = $crawler->selectButton('Create')->form(array(
'cl_customfieldsbundle_blopentity2[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(
'cl_customfieldsbundle_blopentity2[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());
}
*/
}

View File

@ -1,55 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class BlopEntityControllerTest 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', '/blopentity/');
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /blopentity/");
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
// Fill in the form and submit it
$form = $crawler->selectButton('Create')->form(array(
'cl_customfieldsbundle_blopentity[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(
'cl_customfieldsbundle_blopentity[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());
}
*/
}

View File

@ -1,55 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class EntityControllerTest 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', '/entity/');
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /entity/");
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
// Fill in the form and submit it
$form = $crawler->selectButton('Create')->form(array(
'cl_customfieldsbundle_entity[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(
'cl_customfieldsbundle_entity[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());
}
*/
}

View File

@ -1,55 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class TestEntityControllerTest 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', '/testentity/');
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /testentity/");
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
// Fill in the form and submit it
$form = $crawler->selectButton('Create')->form(array(
'cl_customfieldsbundle_testentity[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(
'cl_customfieldsbundle_testentity[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());
}
*/
}

View File

@ -1,55 +0,0 @@
<?php
namespace Chill\CustomFieldsBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class TestExtraColumnControllerTest 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', '/testextracolumn/');
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /testextracolumn/");
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
// Fill in the form and submit it
$form = $crawler->selectButton('Create')->form(array(
'cl_customfieldsbundle_testextracolumn[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(
'cl_customfieldsbundle_testextracolumn[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());
}
*/
}