First commit

This commit is contained in:
Marc Ducobu
2014-09-09 10:46:05 +02:00
parent 6521dd5e2b
commit 9f3d89380d
78 changed files with 5766 additions and 0 deletions

7
src/.htaccess Normal file
View File

@@ -0,0 +1,7 @@
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>

View File

@@ -0,0 +1,9 @@
<?php
namespace CL\CustomFieldsBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class CLCustomFieldsBundle extends Bundle
{
}

View File

@@ -0,0 +1,248 @@
<?php
namespace CL\CustomFieldsBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use CL\CustomFieldsBundle\Entity\BlopEntity;
use CL\CustomFieldsBundle\Form\BlopEntityType;
/**
* BlopEntity controller.
*
*/
class BlopEntityController extends Controller
{
/**
* Lists all BlopEntity entities.
*
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('CLCustomFieldsBundle:BlopEntity')->findAll();
return $this->render('CLCustomFieldsBundle:BlopEntity:index.html.twig', array(
'entities' => $entities,
));
}
public function cfSetAction($id,$key,$value)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('CLCustomFieldsBundle: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('CLCustomFieldsBundle: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('CLCustomFieldsBundle: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('CLCustomFieldsBundle: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('CLCustomFieldsBundle:BlopEntity')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find BlopEntity entity.');
}
$deleteForm = $this->createDeleteForm($id);
return $this->render('CLCustomFieldsBundle: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('CLCustomFieldsBundle:BlopEntity')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find BlopEntity entity.');
}
$editForm = $this->createEditForm($entity);
$deleteForm = $this->createDeleteForm($id);
return $this->render('CLCustomFieldsBundle: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('CLCustomFieldsBundle: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('CLCustomFieldsBundle: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('CLCustomFieldsBundle: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

@@ -0,0 +1,224 @@
<?php
namespace CL\CustomFieldsBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use CL\CustomFieldsBundle\Entity\CustomField;
use CL\CustomFieldsBundle\Form\CustomFieldType;
/**
* CustomField controller.
*
*/
class CustomFieldController extends Controller
{
/**
* Lists all CustomField entities.
*
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('CLCustomFieldsBundle:CustomField')->findAll();
return $this->render('CLCustomFieldsBundle:CustomField:index.html.twig', array(
'entities' => $entities,
));
}
/**
* Creates a new CustomField entity.
*
*/
public function createAction(Request $request)
{
$entity = new CustomField();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('customfield_show', array('id' => $entity->getId())));
}
return $this->render('CLCustomFieldsBundle:CustomField:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
}
/**
* Creates a form to create a CustomField entity.
*
* @param CustomField $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCreateForm(CustomField $entity)
{
$form = $this->createForm(new CustomFieldType(), $entity, array(
'action' => $this->generateUrl('customfield_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
}
/**
* Displays a form to create a new CustomField entity.
*
*/
public function newAction()
{
$entity = new CustomField();
$form = $this->createCreateForm($entity);
return $this->render('CLCustomFieldsBundle:CustomField:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
}
/**
* Finds and displays a CustomField entity.
*
*/
public function showAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('CLCustomFieldsBundle:CustomField')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find CustomField entity.');
}
$deleteForm = $this->createDeleteForm($id);
return $this->render('CLCustomFieldsBundle:CustomField:show.html.twig', array(
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
));
}
/**
* Displays a form to edit an existing CustomField entity.
*
*/
public function editAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('CLCustomFieldsBundle:CustomField')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find CustomField entity.');
}
$editForm = $this->createEditForm($entity);
$deleteForm = $this->createDeleteForm($id);
return $this->render('CLCustomFieldsBundle:CustomField:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Creates a form to edit a CustomField entity.
*
* @param CustomField $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createEditForm(CustomField $entity)
{
$form = $this->createForm(new CustomFieldType(), $entity, array(
'action' => $this->generateUrl('customfield_update', array('id' => $entity->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
}
/**
* Edits an existing CustomField entity.
*
*/
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('CLCustomFieldsBundle:CustomField')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find CustomField entity.');
}
$deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('customfield_edit', array('id' => $id)));
}
return $this->render('CLCustomFieldsBundle:CustomField:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Deletes a CustomField entity.
*
*/
public function deleteAction(Request $request, $id)
{
$form = $this->createDeleteForm($id);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('CLCustomFieldsBundle:CustomField')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find CustomField entity.');
}
$em->remove($entity);
$em->flush();
}
return $this->redirect($this->generateUrl('customfield'));
}
/**
* Creates a form to delete a CustomField 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('customfield_delete', array('id' => $id)))
->setMethod('DELETE')
->add('submit', 'submit', array('label' => 'Delete'))
->getForm()
;
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace CL\CustomFieldsBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
public function indexAction($name)
{
return $this->render('CLCustomFieldsBundle:Default:index.html.twig', array('name' => $name));
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace CL\CustomFieldsBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class CLCustomFieldsExtension extends Extension
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace CL\CustomFieldsBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* This is the class that validates and merges configuration from your app/config files
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('cl_custom_fields');
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.
return $treeBuilder;
}
}

View File

@@ -0,0 +1,142 @@
<?php
namespace CL\CustomFieldsBundle\Entity;
/**
* BlopEntity
*/
class BlopEntity
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $field1;
/**
* @var string
*/
private $field2;
/**
* @var array
*/
private $customField;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* 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($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

@@ -0,0 +1,113 @@
<?php
namespace CL\CustomFieldsBundle\Entity;
/**
* CustomField
*/
class CustomField
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $label;
/**
* @var string
*/
private $type;
/**
* @var boolean
*/
private $active;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set label
*
* @param string $label
*
* @return CustomField
*/
public function setLabel($label)
{
$this->label = $label;
return $this;
}
/**
* Get label
*
* @return string
*/
public function getLabel()
{
return $this->label;
}
/**
* Set type
*
* @param string $type
*
* @return CustomField
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set active
*
* @param boolean $active
*
* @return CustomField
*/
public function setActive($active)
{
$this->active = $active;
return $this;
}
/**
* Get active
*
* @return boolean
*/
public function getActive()
{
return $this->active;
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace CL\CustomFieldsBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use CL\CustomFieldsBundle\Form\Type\CustomFieldType;
class BlopEntityType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$entityManager = $options['em'];
$builder
->add('field1')
->add('field2')
->add('customField',new CustomFieldType($entityManager))
;
}
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'CL\CustomFieldsBundle\Entity\BlopEntity'
));
// supprimer ça en definissant dans services
$resolver->setRequired(array(
'em',
));
$resolver->setAllowedTypes(array(
'em' => 'Doctrine\Common\Persistence\ObjectManager',
));
}
/**
* @return string
*/
public function getName()
{
return 'cl_customfieldsbundle_blopentity';
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace CL\CustomFieldsBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class CustomFieldType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('label')
->add('type')
->add('active')
;
}
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'CL\CustomFieldsBundle\Entity\CustomField'
));
}
/**
* @return string
*/
public function getName()
{
return 'cl_customfieldsbundle_customfield';
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace CL\CustomFieldsBundle\Form\DataTransformer;
use Symfony\Component\Form\DataTransformerInterface;
class JsonCustomFieldToArrayTransformer implements DataTransformerInterface {
public function transform($jsonCustomField)
{
return json_decode($jsonCustomField,true);
}
public function reverseTransform($array)
{
return json_encode($array);
}
}

View File

@@ -0,0 +1,50 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CL\CustomFieldsBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use CL\CustomFieldsBundle\Form\DataTransformer\JsonCustomFieldToArrayTransformer;
use Doctrine\Common\Persistence\ObjectManager;
class CustomFieldType extends AbstractType
{
/**
* @var ObjectManager
*/
private $om;
/**
* @param ObjectManager $om
*/
public function __construct(ObjectManager $om)
{
$this->om = $om;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$customFields = $this->om
->getRepository('CLCustomFieldsBundle:CustomField')
->findAll();
foreach ($customFields as $cf) {
$builder->add($cf->getLabel(), $cf->getType());
}
$builder->addViewTransformer(new JsonCustomFieldToArrayTransformer());
}
public function getName()
{
return 'custom_field';
}
}

View File

@@ -0,0 +1,19 @@
CL\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
lifecycleCallbacks: { }

View File

@@ -0,0 +1,19 @@
CL\CustomFieldsBundle\Entity\CustomField:
type: entity
table: null
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
label:
type: string
length: 255
type:
type: string
length: 255
active:
type: boolean
lifecycleCallbacks: { }

View File

@@ -0,0 +1,8 @@
cl_custom_fields_customfield:
resource: "@CLCustomFieldsBundle/Resources/config/routing/customfield.yml"
prefix: /customfield
cl_custom_fields_blopentity:
resource: "@CLCustomFieldsBundle/Resources/config/routing/blopentity.yml"
prefix: /

View File

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

View File

@@ -0,0 +1,30 @@
customfield:
path: /
defaults: { _controller: "CLCustomFieldsBundle:CustomField:index" }
customfield_show:
path: /{id}/show
defaults: { _controller: "CLCustomFieldsBundle:CustomField:show" }
customfield_new:
path: /new
defaults: { _controller: "CLCustomFieldsBundle:CustomField:new" }
customfield_create:
path: /create
defaults: { _controller: "CLCustomFieldsBundle:CustomField:create" }
requirements: { _method: post }
customfield_edit:
path: /{id}/edit
defaults: { _controller: "CLCustomFieldsBundle:CustomField:edit" }
customfield_update:
path: /{id}/update
defaults: { _controller: "CLCustomFieldsBundle:CustomField:update" }
requirements: { _method: post|put }
customfield_delete:
path: /{id}/delete
defaults: { _controller: "CLCustomFieldsBundle:CustomField:delete" }
requirements: { _method: post|delete }

View File

@@ -0,0 +1,7 @@
parameters:
# cl_custom_fields.example.class: CL\CustomFieldsBundle\Example
services:
# cl_custom_fields.example:
# class: %cl_custom_fields.example.class%
# arguments: [@service_id, "plain_value", %parameter%]

View File

@@ -0,0 +1,16 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>BlopEntity edit</h1>
{{ form(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

@@ -0,0 +1,45 @@
{% 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>{{ 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

@@ -0,0 +1,15 @@
{% 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

@@ -0,0 +1,40 @@
{% 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>{{ 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

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

View File

@@ -0,0 +1,5 @@
{% extends '::base.html.twig' %}
{% block body -%}
{{ form(form) }}
{% endblock %}

View File

@@ -0,0 +1,45 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>CustomField list</h1>
<table class="records_list">
<thead>
<tr>
<th>Id</th>
<th>Label</th>
<th>Type</th>
<th>Active</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td><a href="{{ path('customfield_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
<td>{{ entity.label }}</td>
<td>{{ entity.type }}</td>
<td>{{ entity.active }}</td>
<td>
<ul>
<li>
<a href="{{ path('customfield_show', { 'id': entity.id }) }}">show</a>
</li>
<li>
<a href="{{ path('customfield_edit', { 'id': entity.id }) }}">edit</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('customfield_new') }}">
Create a new entry
</a>
</li>
</ul>
{% endblock %}

View File

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

View File

@@ -0,0 +1,40 @@
{% extends '::base.html.twig' %}
{% block body -%}
<h1>CustomField</h1>
<table class="record_properties">
<tbody>
<tr>
<th>Id</th>
<td>{{ entity.id }}</td>
</tr>
<tr>
<th>Label</th>
<td>{{ entity.label }}</td>
</tr>
<tr>
<th>Type</th>
<td>{{ entity.type }}</td>
</tr>
<tr>
<th>Active</th>
<td>{{ entity.active }}</td>
</tr>
</tbody>
</table>
<ul class="record_actions">
<li>
<a href="{{ path('customfield') }}">
Back to the list
</a>
</li>
<li>
<a href="{{ path('customfield_edit', { 'id': entity.id }) }}">
Edit
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
{% endblock %}

View File

@@ -0,0 +1 @@
Hello {{ name }}!

View File

@@ -0,0 +1,16 @@
{% 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

@@ -0,0 +1,45 @@
{% 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

@@ -0,0 +1,15 @@
{% 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

@@ -0,0 +1,40 @@
{% 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

@@ -0,0 +1,16 @@
{% 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

@@ -0,0 +1,45 @@
{% 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

@@ -0,0 +1,15 @@
{% 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

@@ -0,0 +1,40 @@
{% 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

@@ -0,0 +1,16 @@
{% 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

@@ -0,0 +1,41 @@
{% 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

@@ -0,0 +1,15 @@
{% 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

@@ -0,0 +1,32 @@
{% 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

@@ -0,0 +1,55 @@
<?php
namespace CL\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

@@ -0,0 +1,55 @@
<?php
namespace CL\CustomFieldsBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class CustomFieldControllerTest 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', '/customfield/');
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /customfield/");
$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_customfield[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_customfield[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

@@ -0,0 +1,17 @@
<?php
namespace CL\CustomFieldsBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DefaultControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();
$crawler = $client->request('GET', '/hello/Fabien');
$this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace CL\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

@@ -0,0 +1,55 @@
<?php
namespace CL\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

@@ -0,0 +1,55 @@
<?php
namespace CL\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());
}
*/
}