+
{{ form_start(edit_form) }}
{{ form_widget(edit_form) }}
diff --git a/app/config/config.yml b/app/config/config.yml
index 83b2b26..b67fc3f 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -64,10 +64,3 @@ doctrine:
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
-# Swiftmailer Configuration
-swiftmailer:
- transport: '%mailer_transport%'
- host: '%mailer_host%'
- username: '%mailer_user%'
- password: '%mailer_password%'
- spool: { type: memory }
diff --git a/src/CameraBundle/Controller/PreviouslyOwnedFlashController.php b/src/CameraBundle/Controller/PreviouslyOwnedFlashController.php
new file mode 100644
index 0000000..400fd52
--- /dev/null
+++ b/src/CameraBundle/Controller/PreviouslyOwnedFlashController.php
@@ -0,0 +1,137 @@
+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()
+ ;
+ }
+}
diff --git a/src/CameraBundle/Entity/Camera.php b/src/CameraBundle/Entity/Camera.php
index a4b0cfc..2bccac9 100644
--- a/src/CameraBundle/Entity/Camera.php
+++ b/src/CameraBundle/Entity/Camera.php
@@ -14,6 +14,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Camera
{
+ use PurchasePriceTrait;
+
/**
* @var integer
*
@@ -375,30 +377,6 @@ class Camera
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
*
diff --git a/src/CameraBundle/Entity/Flash.php b/src/CameraBundle/Entity/Flash.php
index 413ddc4..4dae87f 100644
--- a/src/CameraBundle/Entity/Flash.php
+++ b/src/CameraBundle/Entity/Flash.php
@@ -12,6 +12,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Flash
{
+ use PurchasePriceTrait;
+
/**
* @var integer
*
@@ -107,6 +109,13 @@ class Flash
private $serial;
+ /**
+ * @var boolean
+ *
+ * @ORM\Column(name="formerly_owned", type="boolean", nullable=false, options={"default" : false})
+ */
+ private $formerlyOwned = false;
+
/**
* Get id
@@ -310,30 +319,6 @@ class Flash
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
*
@@ -405,4 +390,28 @@ class Flash
{
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;
+ }
}
diff --git a/src/CameraBundle/Entity/Lenses.php b/src/CameraBundle/Entity/Lenses.php
index 1e6709c..a94b60b 100644
--- a/src/CameraBundle/Entity/Lenses.php
+++ b/src/CameraBundle/Entity/Lenses.php
@@ -12,6 +12,8 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Lenses
{
+ use PurchasePriceTrait;
+
/**
* @var integer
*
@@ -390,30 +392,6 @@ class Lenses
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
*
diff --git a/src/CameraBundle/Entity/PreviouslyOwnedCamera.php b/src/CameraBundle/Entity/PreviouslyOwnedCamera.php
index 5736006..fc60588 100644
--- a/src/CameraBundle/Entity/PreviouslyOwnedCamera.php
+++ b/src/CameraBundle/Entity/PreviouslyOwnedCamera.php
@@ -32,7 +32,7 @@ class PreviouslyOwnedCamera
/**
* @var string
*
- * @ORM\Column(name="mount", type="string", length=10, nullable=false)
+ * @ORM\Column(name="mount", type="string", length=32, nullable=false)
*/
private $mount;
diff --git a/src/CameraBundle/Entity/PreviouslyOwnedFlash.php b/src/CameraBundle/Entity/PreviouslyOwnedFlash.php
new file mode 100644
index 0000000..10c996f
--- /dev/null
+++ b/src/CameraBundle/Entity/PreviouslyOwnedFlash.php
@@ -0,0 +1,417 @@
+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;
+ }
+}
diff --git a/src/CameraBundle/Entity/PreviouslyOwnedLenses.php b/src/CameraBundle/Entity/PreviouslyOwnedLenses.php
index 8ead3a3..b39fcec 100644
--- a/src/CameraBundle/Entity/PreviouslyOwnedLenses.php
+++ b/src/CameraBundle/Entity/PreviouslyOwnedLenses.php
@@ -102,7 +102,7 @@ class PreviouslyOwnedLenses
/**
* @var string
*
- * @ORM\Column(name="mount", type="string", length=10, nullable=true)
+ * @ORM\Column(name="mount", type="string", length=40, nullable=true)
*/
private $mount;
diff --git a/src/CameraBundle/Entity/PurchasePriceTrait.php b/src/CameraBundle/Entity/PurchasePriceTrait.php
new file mode 100644
index 0000000..e6c379f
--- /dev/null
+++ b/src/CameraBundle/Entity/PurchasePriceTrait.php
@@ -0,0 +1,29 @@
+purchasePrice = $purchasePrice ?? null;
+
+ return $this;
+ }
+
+ /**
+ * Get purchasePrice
+ *
+ * @return string
+ */
+ public function getPurchasePrice()
+ {
+ return (double) str_replace(['$',','], '', (string)$this->purchasePrice) ?? null;
+ }
+}
\ No newline at end of file
diff --git a/src/CameraBundle/Form/FlashType.php b/src/CameraBundle/Form/FlashType.php
index 99768da..590873e 100644
--- a/src/CameraBundle/Form/FlashType.php
+++ b/src/CameraBundle/Form/FlashType.php
@@ -13,9 +13,21 @@ class FlashType extends AbstractType
*/
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');
}
-
+
/**
* {@inheritdoc}
*/
diff --git a/src/CameraBundle/Form/PreviouslyOwnedFlashType.php b/src/CameraBundle/Form/PreviouslyOwnedFlashType.php
new file mode 100644
index 0000000..2ae2f87
--- /dev/null
+++ b/src/CameraBundle/Form/PreviouslyOwnedFlashType.php
@@ -0,0 +1,38 @@
+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';
+ }
+
+
+}
diff --git a/src/CameraBundle/Tests/Controller/PreviouslyOwnedFlashControllerTest.php b/src/CameraBundle/Tests/Controller/PreviouslyOwnedFlashControllerTest.php
new file mode 100644
index 0000000..d88d3d1
--- /dev/null
+++ b/src/CameraBundle/Tests/Controller/PreviouslyOwnedFlashControllerTest.php
@@ -0,0 +1,55 @@
+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());
+ }
+
+ */
+}