Ugly progress commit

This commit is contained in:
Timothy Warren 2017-11-15 11:34:48 -05:00
parent c6c490027e
commit 5e42f6b833
20 changed files with 913 additions and 89 deletions

View File

@ -13,7 +13,7 @@ class AppKernel extends Kernel
new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(), new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), //new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new CameraBundle(), new CameraBundle(),
@ -26,7 +26,7 @@ class AppKernel extends Kernel
if ('dev' === $this->getEnvironment()) { if ('dev' === $this->getEnvironment()) {
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle(); //$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
} }
} }

View File

@ -39,6 +39,9 @@
<li class="{{ route starts with 'previously-owned-camera' ? 'is-active' }}"> <li class="{{ route starts with 'previously-owned-camera' ? 'is-active' }}">
<a href="{{ path('previously-owned-camera_index') }}">Cameras</a> <a href="{{ path('previously-owned-camera_index') }}">Cameras</a>
</li> </li>
<li class="{{ route starts with 'previously-owned-flash' ? 'is-active' }}">
<a href="{{ path('previously-owned-flash_index') }}">Flashes</a>
</li>
<li class="{{ route starts with 'previously-owned-lens' ? 'is-active' }}"> <li class="{{ route starts with 'previously-owned-lens' ? 'is-active' }}">
<a href="{{ path('previously-owned-lens_index') }}">Lenses</a> <a href="{{ path('previously-owned-lens_index') }}">Lenses</a>
</li> </li>

View File

@ -3,7 +3,7 @@
{% block form %} {% block form %}
<h1>Edit Camera</h1> <h1>Edit Camera</h1>
<div class="callout"> <div class="small callout">
<ul> <ul>
<li> <li>
<a href="{{ path('previously-owned-camera_index') }}">Back to the list</a> <a href="{{ path('previously-owned-camera_index') }}">Back to the list</a>
@ -11,7 +11,7 @@
</ul> </ul>
</div> </div>
<div class="primary callout"> <div class="large primary callout">
{{ form_start(edit_form) }} {{ form_start(edit_form) }}
{{ form_widget(edit_form) }} {{ form_widget(edit_form) }}
<button type="submit" class="button">Update</button> <button type="submit" class="button">Update</button>

View File

@ -0,0 +1,21 @@
{% extends 'base.html.twig' %}
{% block body %}
<h1>Previouslyownedflash edit</h1>
{{ form_start(edit_form) }}
{{ form_widget(edit_form) }}
<input type="submit" value="Edit" />
{{ form_end(edit_form) }}
<ul>
<li>
<a href="{{ path('previously-owned-flash_index') }}">Back to the list</a>
</li>
<li>
{{ form_start(delete_form) }}
<input type="submit" value="Delete">
{{ form_end(delete_form) }}
</li>
</ul>
{% endblock %}

View File

@ -0,0 +1,58 @@
{% extends 'base.html.twig' %}
{% block body %}
<h2>Previously Owned Flashes</h2>
<table>
<thead>
<tr>
<th>Actions</th>
<th>Id</th>
<th>Brand</th>
<th>Model</th>
<th>Isautoflash</th>
<th>Isttl</th>
<th>Ttltype</th>
<th>Ispttl</th>
<th>Pttltype</th>
<th>Guidenumber</th>
<th>Purchaseprice</th>
<th>Batteries</th>
<th>Notes</th>
<th>Serial</th>
</tr>
</thead>
<tbody>
{% for previouslyOwnedFlash in previouslyOwnedFlashes %}
<tr>
<td>
<ul>
<li>
<a href="{{ path('previously-owned-flash_edit', { 'id': previouslyOwnedFlash.id }) }}">edit</a>
</li>
</ul>
</td>
<td><a href="{{ path('previously-owned-flash_show', { 'id': previouslyOwnedFlash.id }) }}">{{ previouslyOwnedFlash.id }}</a></td>
<td>{{ previouslyOwnedFlash.brand }}</td>
<td>{{ previouslyOwnedFlash.model }}</td>
<td>{% if previouslyOwnedFlash.isAutoFlash %}Yes{% else %}No{% endif %}</td>
<td>{% if previouslyOwnedFlash.isTtl %}Yes{% else %}No{% endif %}</td>
<td>{{ previouslyOwnedFlash.ttlType }}</td>
<td>{% if previouslyOwnedFlash.isPTtl %}Yes{% else %}No{% endif %}</td>
<td>{{ previouslyOwnedFlash.pTtlType }}</td>
<td>{{ previouslyOwnedFlash.guideNumber }}</td>
<td>{{ previouslyOwnedFlash.purchasePrice }}</td>
<td>{{ previouslyOwnedFlash.batteries }}</td>
<td>{{ previouslyOwnedFlash.notes }}</td>
<td>{{ previouslyOwnedFlash.serial }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('previously-owned-flash_new') }}">Create a new previouslyOwnedFlash</a>
</li>
</ul>
{% endblock %}

View File

@ -0,0 +1,16 @@
{% extends 'base.html.twig' %}
{% block body %}
<h1>Previouslyownedflash creation</h1>
{{ form_start(form) }}
{{ form_widget(form) }}
<input type="submit" value="Create" />
{{ form_end(form) }}
<ul>
<li>
<a href="{{ path('previously-owned-flash_index') }}">Back to the list</a>
</li>
</ul>
{% endblock %}

View File

@ -0,0 +1,80 @@
{% extends 'base.html.twig' %}
{% block body %}
<h1>Previouslyownedflash</h1>
<table>
<tbody>
<tr>
<th>Id</th>
<td>{{ previouslyOwnedFlash.id }}</td>
</tr>
<tr>
<th>Brand</th>
<td>{{ previouslyOwnedFlash.brand }}</td>
</tr>
<tr>
<th>Model</th>
<td>{{ previouslyOwnedFlash.model }}</td>
</tr>
<tr>
<th>Isautoflash</th>
<td>{% if previouslyOwnedFlash.isAutoFlash %}Yes{% else %}No{% endif %}</td>
</tr>
<tr>
<th>Isttl</th>
<td>{% if previouslyOwnedFlash.isTtl %}Yes{% else %}No{% endif %}</td>
</tr>
<tr>
<th>Ttltype</th>
<td>{{ previouslyOwnedFlash.ttlType }}</td>
</tr>
<tr>
<th>Ispttl</th>
<td>{% if previouslyOwnedFlash.isPTtl %}Yes{% else %}No{% endif %}</td>
</tr>
<tr>
<th>Pttltype</th>
<td>{{ previouslyOwnedFlash.pTtlType }}</td>
</tr>
<tr>
<th>Guidenumber</th>
<td>{{ previouslyOwnedFlash.guideNumber }}</td>
</tr>
<tr>
<th>Purchaseprice</th>
<td>{{ previouslyOwnedFlash.purchasePrice }}</td>
</tr>
<tr>
<th>Batteries</th>
<td>{{ previouslyOwnedFlash.batteries }}</td>
</tr>
<tr>
<th>Notes</th>
<td>{{ previouslyOwnedFlash.notes }}</td>
</tr>
<tr>
<th>Serial</th>
<td>{{ previouslyOwnedFlash.serial }}</td>
</tr>
<tr>
<th>Formerlyowned</th>
<td>{% if previouslyOwnedFlash.formerlyOwned %}Yes{% else %}No{% endif %}</td>
</tr>
</tbody>
</table>
<ul>
<li>
<a href="{{ path('previously-owned-flash_index') }}">Back to the list</a>
</li>
<li>
<a href="{{ path('previously-owned-flash_edit', { 'id': previouslyOwnedFlash.id }) }}">Edit</a>
</li>
<li>
{{ form_start(delete_form) }}
<input type="submit" value="Delete">
{{ form_end(delete_form) }}
</li>
</ul>
{% endblock %}

View File

@ -3,7 +3,7 @@
{% block form %} {% block form %}
<h1>Edit Lens</h1> <h1>Edit Lens</h1>
<div class="callout"> <div class="small callout">
<ul> <ul>
<li> <li>
<a href="{{ path('previously-owned-lens_index') }}">Back to the list</a> <a href="{{ path('previously-owned-lens_index') }}">Back to the list</a>
@ -11,7 +11,7 @@
</ul> </ul>
</div> </div>
<div class="primary callout"> <div class="large primary callout">
{{ form_start(edit_form) }} {{ form_start(edit_form) }}
{{ form_widget(edit_form) }} {{ form_widget(edit_form) }}
<button type="submit" class="button">Update</button> <button type="submit" class="button">Update</button>

View File

@ -64,10 +64,3 @@ doctrine:
naming_strategy: doctrine.orm.naming_strategy.underscore naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }

View File

@ -0,0 +1,137 @@
<?php
namespace CameraBundle\Controller;
use CameraBundle\Entity\PreviouslyOwnedFlash;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
/**
* Previouslyownedflash controller.
*
* @Route("previously-owned-flash")
*/
class PreviouslyOwnedFlashController extends Controller
{
/**
* Lists all previouslyOwnedFlash entities.
*
* @Route("/", name="previously-owned-flash_index")
* @Method("GET")
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$previouslyOwnedFlashes = $em->getRepository('CameraBundle:PreviouslyOwnedFlash')->findAll();
return $this->render('previouslyownedflash/index.html.twig', array(
'previouslyOwnedFlashes' => $previouslyOwnedFlashes,
));
}
/**
* Creates a new previouslyOwnedFlash entity.
*
* @Route("/new", name="previously-owned-flash_new")
* @Method({"GET", "POST"})
*/
public function newAction(Request $request)
{
$previouslyOwnedFlash = new Previouslyownedflash();
$form = $this->createForm('CameraBundle\Form\PreviouslyOwnedFlashType', $previouslyOwnedFlash);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($previouslyOwnedFlash);
$em->flush();
return $this->redirectToRoute('previously-owned-flash_show', array('id' => $previouslyOwnedFlash->getId()));
}
return $this->render('previouslyownedflash/new.html.twig', array(
'previouslyOwnedFlash' => $previouslyOwnedFlash,
'form' => $form->createView(),
));
}
/**
* Finds and displays a previouslyOwnedFlash entity.
*
* @Route("/{id}", name="previously-owned-flash_show")
* @Method("GET")
*/
public function showAction(PreviouslyOwnedFlash $previouslyOwnedFlash)
{
$deleteForm = $this->createDeleteForm($previouslyOwnedFlash);
return $this->render('previouslyownedflash/show.html.twig', array(
'previouslyOwnedFlash' => $previouslyOwnedFlash,
'delete_form' => $deleteForm->createView(),
));
}
/**
* Displays a form to edit an existing previouslyOwnedFlash entity.
*
* @Route("/{id}/edit", name="previously-owned-flash_edit")
* @Method({"GET", "POST"})
*/
public function editAction(Request $request, PreviouslyOwnedFlash $previouslyOwnedFlash)
{
$deleteForm = $this->createDeleteForm($previouslyOwnedFlash);
$editForm = $this->createForm('CameraBundle\Form\PreviouslyOwnedFlashType', $previouslyOwnedFlash);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('previously-owned-flash_edit', array('id' => $previouslyOwnedFlash->getId()));
}
return $this->render('previouslyownedflash/edit.html.twig', array(
'previouslyOwnedFlash' => $previouslyOwnedFlash,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Deletes a previouslyOwnedFlash entity.
*
* @Route("/{id}", name="previously-owned-flash_delete")
* @Method("DELETE")
*/
public function deleteAction(Request $request, PreviouslyOwnedFlash $previouslyOwnedFlash)
{
$form = $this->createDeleteForm($previouslyOwnedFlash);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($previouslyOwnedFlash);
$em->flush();
}
return $this->redirectToRoute('previously-owned-flash_index');
}
/**
* Creates a form to delete a previouslyOwnedFlash entity.
*
* @param PreviouslyOwnedFlash $previouslyOwnedFlash The previouslyOwnedFlash entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm(PreviouslyOwnedFlash $previouslyOwnedFlash)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('previously-owned-flash_delete', array('id' => $previouslyOwnedFlash->getId())))
->setMethod('DELETE')
->getForm()
;
}
}

View File

@ -14,6 +14,8 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
class Camera class Camera
{ {
use PurchasePriceTrait;
/** /**
* @var integer * @var integer
* *
@ -375,30 +377,6 @@ class Camera
return $this->formerlyOwned; return $this->formerlyOwned;
} }
/**
* Set purchasePrice
*
* @param string $purchasePrice
*
* @return Camera
*/
public function setPurchasePrice($purchasePrice)
{
$this->purchasePrice = $purchasePrice ?? 0;
return $this;
}
/**
* Get purchasePrice
*
* @return string
*/
public function getPurchasePrice()
{
return (double) str_replace('$', '', (string)$this->purchasePrice) ?? 0;
}
/** /**
* Set batteryType * Set batteryType
* *

View File

@ -12,6 +12,8 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
class Flash class Flash
{ {
use PurchasePriceTrait;
/** /**
* @var integer * @var integer
* *
@ -107,6 +109,13 @@ class Flash
private $serial; private $serial;
/**
* @var boolean
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false, options={"default" : false})
*/
private $formerlyOwned = false;
/** /**
* Get id * Get id
@ -310,30 +319,6 @@ class Flash
return $this->guideNumber; return $this->guideNumber;
} }
/**
* Set purchasePrice
*
* @param string $purchasePrice
*
* @return Camera
*/
public function setPurchasePrice($purchasePrice)
{
$this->purchasePrice = $purchasePrice ?? 0;
return $this;
}
/**
* Get purchasePrice
*
* @return string
*/
public function getPurchasePrice()
{
return (double) str_replace('$', '', (string)$this->purchasePrice) ?? 0;
}
/** /**
* Set batteries * Set batteries
* *
@ -405,4 +390,28 @@ class Flash
{ {
return $this->serial; return $this->serial;
} }
/**
* Set formerlyOwned
*
* @param boolean $formerlyOwned
*
* @return Flash
*/
public function setFormerlyOwned($formerlyOwned)
{
$this->formerlyOwned = $formerlyOwned;
return $this;
}
/**
* Get formerlyOwned
*
* @return boolean
*/
public function getFormerlyOwned()
{
return $this->formerlyOwned;
}
} }

View File

@ -12,6 +12,8 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
class Lenses class Lenses
{ {
use PurchasePriceTrait;
/** /**
* @var integer * @var integer
* *
@ -390,30 +392,6 @@ class Lenses
return $this->serial; return $this->serial;
} }
/**
* Set purchasePrice
*
* @param string $purchasePrice
*
* @return Camera
*/
public function setPurchasePrice($purchasePrice)
{
$this->purchasePrice = $purchasePrice ?? 0;
return $this;
}
/**
* Get purchasePrice
*
* @return string
*/
public function getPurchasePrice()
{
return (double) str_replace('$', '', (string)$this->purchasePrice) ?? 0;
}
/** /**
* Set notes * Set notes
* *

View File

@ -32,7 +32,7 @@ class PreviouslyOwnedCamera
/** /**
* @var string * @var string
* *
* @ORM\Column(name="mount", type="string", length=10, nullable=false) * @ORM\Column(name="mount", type="string", length=32, nullable=false)
*/ */
private $mount; private $mount;

View File

@ -0,0 +1,417 @@
<?php
namespace CameraBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Camera.flash
*
* @ORM\Table(name="previously_owned_flash", schema="camera")
* @ORM\Entity
*/
class PreviouslyOwnedFlash extends Flash
{
use PurchasePriceTrait;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="camera.previously_owned_flash_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="brand", type="string", nullable=false)
*/
private $brand;
/**
* @var string
*
* @ORM\Column(name="model", type="string", nullable=false)
*/
private $model;
/**
* @var boolean
*
* @ORM\Column(name="is_auto_flash", type="boolean", nullable=false)
*/
private $isAutoFlash = false;
/**
* @var boolean
*
* @ORM\Column(name="is_ttl", type="boolean", nullable=false)
*/
private $isTtl = false;
/**
* @var string
*
* @ORM\Column(name="ttl_type", type="string", nullable=false)
*/
private $ttlType = 'N / A';
/**
* @var boolean
*
* @ORM\Column(name="is_p_ttl", type="boolean", nullable=false)
*/
private $isPTtl = false;
/**
* @var string
*
* @ORM\Column(name="p_ttl_type", type="string", nullable=false)
*/
private $pTtlType = 'N / A';
/**
* @var string
*
* @ORM\Column(name="guide_number", type="string", nullable=true)
*/
private $guideNumber;
/**
* @var string
*
* @ORM\Column(name="purchase_price", type="decimal", precision=10, scale=0, nullable=true)
*/
private $purchasePrice;
/**
* @var string
*
* @ORM\Column(name="batteries", type="string", nullable=false)
*/
private $batteries = '4x AA';
/**
* @var string
*
* @ORM\Column(name="notes", type="text", nullable=true)
*/
private $notes;
/**
* @var string
*
* @ORM\Column(name="serial", type="string", nullable=true)
*/
private $serial;
/**
* @var boolean
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false, options={"default" : false})
*/
private $formerlyOwned = true;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set brand
*
* @param string $brand
*
* @return Flash
*/
public function setBrand($brand)
{
$this->brand = $brand;
return $this;
}
/**
* Get brand
*
* @return string
*/
public function getBrand()
{
return $this->brand;
}
/**
* Set model
*
* @param string $model
*
* @return Flash
*/
public function setModel($model)
{
$this->model = $model;
return $this;
}
/**
* Get model
*
* @return string
*/
public function getModel()
{
return $this->model;
}
/**
* Set isAutoFlash
*
* @param boolean $isAutoFlash
*
* @return Flash
*/
public function setIsAutoFlash($isAutoFlash)
{
$this->isAutoFlash = $isAutoFlash;
return $this;
}
/**
* Get isAutoFlash
*
* @return boolean
*/
public function getIsAutoFlash()
{
return $this->isAutoFlash;
}
/**
* Set isTtl
*
* @param boolean $isTtl
*
* @return Flash
*/
public function setIsTtl($isTtl)
{
$this->isTtl = $isTtl;
return $this;
}
/**
* Get isTtl
*
* @return boolean
*/
public function getIsTtl()
{
return $this->isTtl;
}
/**
* Set ttlType
*
* @param string $ttlType
*
* @return Flash
*/
public function setTtlType($ttlType)
{
$this->ttlType = $ttlType;
return $this;
}
/**
* Get ttlType
*
* @return string
*/
public function getTtlType()
{
return $this->ttlType;
}
/**
* Set isPTtl
*
* @param boolean $isPTtl
*
* @return Flash
*/
public function setIsPTtl($isPTtl)
{
$this->isPTtl = $isPTtl;
return $this;
}
/**
* Get isPTtl
*
* @return boolean
*/
public function getIsPTtl()
{
return $this->isPTtl;
}
/**
* Set pTtlType
*
* @param string $pTtlType
*
* @return Flash
*/
public function setPTtlType($pTtlType)
{
$this->pTtlType = $pTtlType;
return $this;
}
/**
* Get pTtlType
*
* @return string
*/
public function getPTtlType()
{
return $this->pTtlType;
}
/**
* Set guideNumber
*
* @param string $guideNumber
*
* @return Flash
*/
public function setGuideNumber($guideNumber)
{
$this->guideNumber = $guideNumber;
return $this;
}
/**
* Get guideNumber
*
* @return string
*/
public function getGuideNumber()
{
return $this->guideNumber;
}
/**
* Set batteries
*
* @param string $batteries
*
* @return Flash
*/
public function setBatteries($batteries)
{
$this->batteries = $batteries;
return $this;
}
/**
* Get batteries
*
* @return string
*/
public function getBatteries()
{
return $this->batteries;
}
/**
* Set notes
*
* @param string $notes
*
* @return Flash
*/
public function setNotes($notes)
{
$this->notes = $notes;
return $this;
}
/**
* Get notes
*
* @return string
*/
public function getNotes()
{
return $this->notes;
}
/**
* Set serial
*
* @param string $serial
*
* @return Flash
*/
public function setSerial($serial)
{
$this->serial = $serial;
return $this;
}
/**
* Get serial
*
* @return string
*/
public function getSerial()
{
return $this->serial;
}
/**
* Set formerlyOwned
*
* @param boolean $formerlyOwned
*
* @return Flash
*/
public function setFormerlyOwned($formerlyOwned)
{
$this->formerlyOwned = $formerlyOwned;
return $this;
}
/**
* Get formerlyOwned
*
* @return boolean
*/
public function getFormerlyOwned()
{
return $this->formerlyOwned;
}
}

View File

@ -102,7 +102,7 @@ class PreviouslyOwnedLenses
/** /**
* @var string * @var string
* *
* @ORM\Column(name="mount", type="string", length=10, nullable=true) * @ORM\Column(name="mount", type="string", length=40, nullable=true)
*/ */
private $mount; private $mount;

View File

@ -0,0 +1,29 @@
<?php
namespace CameraBundle\Entity;
trait PurchasePriceTrait {
/**
* Set purchasePrice
*
* @param string $purchasePrice
*
* @return Camera
*/
public function setPurchasePrice($purchasePrice)
{
$this->purchasePrice = $purchasePrice ?? null;
return $this;
}
/**
* Get purchasePrice
*
* @return string
*/
public function getPurchasePrice()
{
return (double) str_replace(['$',','], '', (string)$this->purchasePrice) ?? null;
}
}

View File

@ -13,7 +13,19 @@ class FlashType extends AbstractType
*/ */
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->add('brand')->add('model')->add('isAutoFlash')->add('isTtl')->add('ttlType')->add('isPTtl')->add('pTtlType')->add('guideNumber')->add('purchasePrice')->add('batteries')->add('notes')->add('serial'); $builder->add('brand')
->add('model')
->add('isAutoFlash')
->add('isTtl')
->add('ttlType')
->add('isPTtl')
->add('pTtlType')
->add('guideNumber')
->add('purchasePrice')
->add('batteries')
->add('notes')
->add('serial')
->add('formerlyOwned');
} }
/** /**

View File

@ -0,0 +1,38 @@
<?php
namespace CameraBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class PreviouslyOwnedFlashType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('brand')->add('model')->add('isAutoFlash')->add('isTtl')->add('ttlType')->add('isPTtl')->add('pTtlType')->add('guideNumber')->add('purchasePrice')->add('batteries')->add('notes')->add('serial')->add('formerlyOwned');
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'CameraBundle\Entity\PreviouslyOwnedFlash'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'camerabundle_previouslyownedflash';
}
}

View File

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