From 8bc17441d7605693569e2edd84cf497919546058 Mon Sep 17 00:00:00 2001 From: Guite Date: Thu, 4 Oct 2018 08:37:34 +0200 Subject: [PATCH] fixed #83 --- Entity/SubmissionEntity.php | 39 ++++++++++++++++++++ FormiculaModuleInstaller.php | 13 ++++++- Resources/views/Submission/delete.html.twig | 2 +- Resources/views/Submission/display.html.twig | 8 ++-- Resources/views/Submission/view.html.twig | 6 +-- 5 files changed, 59 insertions(+), 9 deletions(-) diff --git a/Entity/SubmissionEntity.php b/Entity/SubmissionEntity.php index c3aa156..22bcf69 100644 --- a/Entity/SubmissionEntity.php +++ b/Entity/SubmissionEntity.php @@ -100,6 +100,14 @@ class SubmissionEntity extends EntityAccess */ private $phoneNumber; + /** + * The company + * + * @ORM\Column(type="string", length=255) + * @var string $company + */ + private $company; + /** * The url * @@ -145,6 +153,7 @@ public function __construct() $this->name = ''; $this->email = ''; $this->phoneNumber = ''; + $this->company = ''; $this->url = ''; $this->location = ''; $this->comment = ''; @@ -311,6 +320,36 @@ public function setPhoneNumber($phoneNumber) $this->phoneNumber = $phoneNumber; } + /** + * Alias for easier form handling. + * + * @param string $phoneNumber the submission's phone number + */ + public function setPhone($phoneNumber) + { + return $this->setPhoneNumber($phoneNumber); + } + + /** + * Gets the company of the submission. + * + * @return string the submission's company + */ + public function getCompany() + { + return $this->company; + } + + /** + * Sets the company for the submission. + * + * @param string $company the submission's company + */ + public function setCompany($company) + { + $this->company = $company; + } + /** * Gets the url of the submission. * diff --git a/FormiculaModuleInstaller.php b/FormiculaModuleInstaller.php index ef60703..e6d8871 100644 --- a/FormiculaModuleInstaller.php +++ b/FormiculaModuleInstaller.php @@ -27,7 +27,7 @@ class FormiculaModuleInstaller extends AbstractExtensionInstaller */ private $entities = [ 'Zikula\FormiculaModule\Entity\ContactEntity', - 'Zikula\FormiculaModule\Entity\SubmissionEntity', + 'Zikula\FormiculaModule\Entity\SubmissionEntity' ]; /** @@ -194,6 +194,17 @@ public function upgrade($oldVersion) $stmt = $connection->prepare($sql); $stmt->execute(); case '5.0.0': + // added forgotten company field + try { + $this->schemaTool->update([ + 'Zikula\FormiculaModule\Entity\SubmissionEntity' + ]); + } catch (\Exception $exception) { + $this->addFlash('error', $this->__('Doctrine Exception') . ': ' . $exception->getMessage()); + + return false; + } + case '5.0.1': // future upgrades } diff --git a/Resources/views/Submission/delete.html.twig b/Resources/views/Submission/delete.html.twig index 7ecbff8..6a2ee60 100644 --- a/Resources/views/Submission/delete.html.twig +++ b/Resources/views/Submission/delete.html.twig @@ -44,7 +44,7 @@
diff --git a/Resources/views/Submission/display.html.twig b/Resources/views/Submission/display.html.twig index b37876f..8bc5999 100644 --- a/Resources/views/Submission/display.html.twig +++ b/Resources/views/Submission/display.html.twig @@ -24,7 +24,7 @@ {{ submission.createdDate|localizeddate('short', 'short') }} - {{ submission.name }} + {{ submission.name }} {{ submission.ipAddress }} {{ submission.hostName }} {{ submission.cid }} @@ -49,9 +49,9 @@ {% if submission.url != '' %}{{ submission.url }}{% else %}{{ __('None') }}{% endif %} - {% if submission.company != '' %}{{ submission.company }}{% else %}{{ __('None') }}{% endif %} - {% if submission.phoneNumber != '' %}{{ submission.phoneNumber }}{% else %}{{ __('None') }}{% endif %} - {% if submission.location != '' %}{{ submission.location }}{% else %}{{ __('None') }}{% endif %} + {{ submission.company|default(__('None')) }} + {{ submission.phoneNumber|default(__('None')) }} + {{ submission.location|default(__('None')) }} diff --git a/Resources/views/Submission/view.html.twig b/Resources/views/Submission/view.html.twig index 6fe9785..58092d9 100644 --- a/Resources/views/Submission/view.html.twig +++ b/Resources/views/Submission/view.html.twig @@ -30,10 +30,10 @@ {{ submission.form }} {{ submission.cid }} {{ submission.createdDate|localizeddate('short', 'short') }} - {{ submission.name }} + {{ submission.name }} - - + + {% else %}