Skip to content
Snippets Groups Projects
Commit 6128fd53 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Using contact for email addreess, ts setting for default contact....

[TASK] Using contact for email addreess, ts setting for default contact. General issues with the models
parent d33d4b0f
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ namespace SGalinski\SgJobs\Controller;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use SGalinski\SgJobs\Domain\Model\Contact;
use SGalinski\SgJobs\Domain\Model\Job;
use SGalinski\SgJobs\Domain\Model\JobApplication;
use SGalinski\SgJobs\Property\TypeConverter\UploadedFileReferenceConverter;
......@@ -55,6 +56,12 @@ class JoblistController extends ActionController {
*/
private $jobRepository;
/**
* @var \SGalinski\SgJobs\Domain\Repository\ContactRepository
* @inject
*/
private $contactRepository;
/**
* @var \SGalinski\SgJobs\Domain\Repository\JobApplicationRepository
* @inject
......@@ -243,6 +250,24 @@ class JoblistController extends ActionController {
MailTemplateService::class, 'application_mail', 'sg_jobs',
$this->getApplicationMailMarkers($applyData)
);
// get email from the job contact, fallback is TS settings
/** @var Job $job */
$job = $applyData->getJob();
if ($job !== NULL) {
/** @var Contact $contact */
$contact = $job->getContact();
if ($contact === NULL) {
$contact = $this->contactRepository->findByUid((int) $this->settings['defaultContactId']);
}
} else {
$contact = $this->contactRepository->findByUid((int) $this->settings['defaultContactId']);
}
if ($contact !== NULL) {
$mailService->setToAddresses($contact->getEmail());
}
$mailService->setMarkers(['application' => $applyData]);
$mailService->setIgnoreMailQueue(TRUE);
......
......@@ -79,7 +79,7 @@ class Job extends AbstractEntity {
protected $description = '';
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\SGalinski\SgJobs\Domain\Model\Contact> $contact
* @var \SGalinski\SgJobs\Domain\Model\Contact $contact
*/
protected $contact;
......@@ -182,16 +182,16 @@ class Job extends AbstractEntity {
}
/**
* @return ObjectStorage
* @return \SGalinski\SgJobs\Domain\Model\Contact
*/
public function getContact() {
return $this->contact;
}
/**
* @param ObjectStorage $contact
* @param \SGalinski\SgJobs\Domain\Model\Contact $contact
*/
public function setContact(ObjectStorage $contact) {
public function setContact(Contact $contact) {
$this->contact = $contact;
}
......
......@@ -27,6 +27,7 @@ namespace SGalinski\SgJobs\Domain\Model;
***************************************************************/
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
......@@ -46,7 +47,7 @@ class JobApplication extends AbstractEntity {
protected $jobTitle = '';
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\SGalinski\SgJobs\Domain\Model\Job> $job
* @var \SGalinski\SgJobs\Domain\Model\Job $job
*/
protected $job;
......@@ -417,16 +418,16 @@ class JobApplication extends AbstractEntity {
}
/**
* @return ObjectStorage
* @return \SGalinski\SgJobs\Domain\Model\Job
*/
public function getJob() {
return $this->job;
}
/**
* @param ObjectStorage $job
* @param \SGalinski\SgJobs\Domain\Model\Job $job
*/
public function setJob(ObjectStorage $job) {
public function setJob(Job $job) {
$this->job = $job;
}
}
......@@ -24,6 +24,7 @@ plugin.tx_sgjobs {
settings {
allowedFileExtensions = {$plugin.tx_sgjobs.settings.allowedFileExtensions}
allowedMimeTypes = {$plugin.tx_sgjobs.settings.allowedMimeTypes}
defaultContactId =
}
features {
......
......@@ -81,21 +81,21 @@
<div>
<h3><f:translate key="frontend.email" /></h3>
<p>
{job.contact.0.email}
{job.contact.email}
</p>
</div>
<f:debug>{job}</f:debug>
<div>
<h3><f:translate key="frontend.apply_by_mail" /></h3>
{job.company.0.name}
<br />
{job.contact.0.firstName} {job.contact.0.lastName}
{job.contact.firstName} {job.contact.0.lastName}
<br />
{job.company.0.street}
<br />
{job.company.0.city}
<br />
{job.contact.0.email}
{job.contact.email}
<br />
{job.contact.0.phone}
{job.contact.phone}
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment