initial commit
[namibia] / module / Company / src / Company / Service / CompanyRetail.php
1 <?php
2 namespace Company\Service;
3
4
5
6 /**
7  * Manage Company data.
8  * @author andre.fourie
9  */
10 class CompanyRetail extends \Company\DataBin\CompanyRetail
11 {
12
13
14
15         /**
16          * ConditionalContract: Create.
17          * @param array $meta
18          * @param object|null $jobRecord
19          * @param object|null $record
20          * @param \Workspace\Contract\AbstractBase $contract
21          * @return array
22          */
23         public function noDuplicateRetailEntries($meta, $jobRecord, $record, \Workspace\Contract\AbstractBase $contract)
24         {
25                 $duplicate = $this->em
26                         ->getRepository('\Company\Entity\CompanyRetail')
27                         ->findOneBy(array(
28                                 'company'  => $jobRecord->company->id,
29                                 'retail'   => $jobRecord->retail->id,
30                                 'archived' => false
31                         ));
32                 if (!is_null($duplicate))
33                 {
34                         throw new \Exception('Found existing entry for this Retailer, only one account allowed per retailer.');
35                 }
36         }
37
38
39 }