diff --git a/app/AppKernel.php b/app/AppKernel.php index 72b97b7..e3fdf36 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -13,7 +13,7 @@ class AppKernel extends Kernel new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\MonologBundle\MonologBundle(), - new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), + //new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new CameraBundle(), @@ -26,7 +26,7 @@ class AppKernel extends Kernel if ('dev' === $this->getEnvironment()) { $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); - $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle(); + //$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle(); } } diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig index c3f5062..8855e20 100644 --- a/app/Resources/views/base.html.twig +++ b/app/Resources/views/base.html.twig @@ -39,6 +39,9 @@
  • Cameras
  • +
  • + Flashes +
  • Lenses
  • diff --git a/app/Resources/views/previouslyownedcamera/edit.html.twig b/app/Resources/views/previouslyownedcamera/edit.html.twig index 2d9f1a0..97fe29c 100644 --- a/app/Resources/views/previouslyownedcamera/edit.html.twig +++ b/app/Resources/views/previouslyownedcamera/edit.html.twig @@ -3,7 +3,7 @@ {% block form %}

    Edit Camera

    -
    +
    -
    +
    {{ form_start(edit_form) }} {{ form_widget(edit_form) }} diff --git a/app/Resources/views/previouslyownedflash/edit.html.twig b/app/Resources/views/previouslyownedflash/edit.html.twig new file mode 100644 index 0000000..fd49bf1 --- /dev/null +++ b/app/Resources/views/previouslyownedflash/edit.html.twig @@ -0,0 +1,21 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

    Previouslyownedflash edit

    + + {{ form_start(edit_form) }} + {{ form_widget(edit_form) }} + + {{ form_end(edit_form) }} + +
      +
    • + Back to the list +
    • +
    • + {{ form_start(delete_form) }} + + {{ form_end(delete_form) }} +
    • +
    +{% endblock %} diff --git a/app/Resources/views/previouslyownedflash/index.html.twig b/app/Resources/views/previouslyownedflash/index.html.twig new file mode 100644 index 0000000..13af562 --- /dev/null +++ b/app/Resources/views/previouslyownedflash/index.html.twig @@ -0,0 +1,58 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

    Previously Owned Flashes

    + + + + + + + + + + + + + + + + + + + + + + {% for previouslyOwnedFlash in previouslyOwnedFlashes %} + + + + + + + + + + + + + + + + + {% endfor %} + +
    ActionsIdBrandModelIsautoflashIsttlTtltypeIspttlPttltypeGuidenumberPurchasepriceBatteriesNotesSerial
    + + {{ previouslyOwnedFlash.id }}{{ previouslyOwnedFlash.brand }}{{ previouslyOwnedFlash.model }}{% if previouslyOwnedFlash.isAutoFlash %}Yes{% else %}No{% endif %}{% if previouslyOwnedFlash.isTtl %}Yes{% else %}No{% endif %}{{ previouslyOwnedFlash.ttlType }}{% if previouslyOwnedFlash.isPTtl %}Yes{% else %}No{% endif %}{{ previouslyOwnedFlash.pTtlType }}{{ previouslyOwnedFlash.guideNumber }}{{ previouslyOwnedFlash.purchasePrice }}{{ previouslyOwnedFlash.batteries }}{{ previouslyOwnedFlash.notes }}{{ previouslyOwnedFlash.serial }}
    + + +{% endblock %} diff --git a/app/Resources/views/previouslyownedflash/new.html.twig b/app/Resources/views/previouslyownedflash/new.html.twig new file mode 100644 index 0000000..019063a --- /dev/null +++ b/app/Resources/views/previouslyownedflash/new.html.twig @@ -0,0 +1,16 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

    Previouslyownedflash creation

    + + {{ form_start(form) }} + {{ form_widget(form) }} + + {{ form_end(form) }} + + +{% endblock %} diff --git a/app/Resources/views/previouslyownedflash/show.html.twig b/app/Resources/views/previouslyownedflash/show.html.twig new file mode 100644 index 0000000..743d6ed --- /dev/null +++ b/app/Resources/views/previouslyownedflash/show.html.twig @@ -0,0 +1,80 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

    Previouslyownedflash

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Id{{ previouslyOwnedFlash.id }}
    Brand{{ previouslyOwnedFlash.brand }}
    Model{{ previouslyOwnedFlash.model }}
    Isautoflash{% if previouslyOwnedFlash.isAutoFlash %}Yes{% else %}No{% endif %}
    Isttl{% if previouslyOwnedFlash.isTtl %}Yes{% else %}No{% endif %}
    Ttltype{{ previouslyOwnedFlash.ttlType }}
    Ispttl{% if previouslyOwnedFlash.isPTtl %}Yes{% else %}No{% endif %}
    Pttltype{{ previouslyOwnedFlash.pTtlType }}
    Guidenumber{{ previouslyOwnedFlash.guideNumber }}
    Purchaseprice{{ previouslyOwnedFlash.purchasePrice }}
    Batteries{{ previouslyOwnedFlash.batteries }}
    Notes{{ previouslyOwnedFlash.notes }}
    Serial{{ previouslyOwnedFlash.serial }}
    Formerlyowned{% if previouslyOwnedFlash.formerlyOwned %}Yes{% else %}No{% endif %}
    + +
      +
    • + Back to the list +
    • +
    • + Edit +
    • +
    • + {{ form_start(delete_form) }} + + {{ form_end(delete_form) }} +
    • +
    +{% endblock %} diff --git a/app/Resources/views/previouslyownedlenses/edit.html.twig b/app/Resources/views/previouslyownedlenses/edit.html.twig index e0a4e56..5d81269 100644 --- a/app/Resources/views/previouslyownedlenses/edit.html.twig +++ b/app/Resources/views/previouslyownedlenses/edit.html.twig @@ -3,7 +3,7 @@ {% block form %}

    Edit Lens

    -
    +
    -
    +
    {{ 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()); + } + + */ +}