This repository has been archived by the owner on Apr 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07e8759
commit 08b2f8f
Showing
18 changed files
with
197 additions
and
466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
namespace Opg\Common\Model\Entity; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Opg\Core\Model\Entity\CaseItem\CaseItem; | ||
|
||
/** | ||
* Interface HasCasesInterface | ||
* @package Opg\Core\Model\Entity\CaseActor\Interfaces | ||
*/ | ||
interface HasCasesInterface | ||
{ | ||
/** | ||
* @return ArrayCollection | ||
*/ | ||
public function getCases(); | ||
|
||
/** | ||
* @param ArrayCollection $caseCollection | ||
* | ||
* @return HasCasesInterface | ||
*/ | ||
public function setCases(ArrayCollection $caseCollection); | ||
|
||
/** | ||
* @param CaseItem $caseItem | ||
* @return HasCasesInterface | ||
*/ | ||
public function addCase(CaseItem $caseItem); | ||
|
||
/** | ||
* @param CaseItem $caseItem | ||
* @return HasCasesInterface | ||
*/ | ||
public function removeCase(CaseItem $caseItem); | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function hasAttachedCase(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
|
||
namespace Opg\Common\Model\Entity\Traits; | ||
|
||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Opg\Common\Model\Entity\HasCasesInterface; | ||
use Opg\Core\Model\Entity\CaseItem\CaseItem; | ||
|
||
/** | ||
* Class HasCases | ||
* @package Opg\Common\Model\Entity\Traits | ||
*/ | ||
trait HasCases | ||
{ | ||
|
||
/** | ||
* @ORM\ManyToMany(targetEntity="Opg\Core\Model\Entity\CaseItem\CaseItem", cascade={"persist"}) | ||
* @ORM\OrderBy({"id"="ASC"}) | ||
* @var ArrayCollection | ||
* @Groups({"api-person-get"}) | ||
*/ | ||
protected $cases; | ||
|
||
/** | ||
* @return ArrayCollection | ||
*/ | ||
public function getCases() | ||
{ | ||
$this->initCases(); | ||
|
||
return $this->cases; | ||
} | ||
|
||
/** | ||
* @param ArrayCollection $caseCollection | ||
* | ||
* @return HasCasesInterface | ||
*/ | ||
public function setCases(ArrayCollection $caseCollection) | ||
{ | ||
$this->cases = $caseCollection; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param CaseItem $caseItem | ||
* @return HasCasesInterface | ||
*/ | ||
public function addCase(CaseItem $caseItem) | ||
{ | ||
$this->initCases(); | ||
|
||
if (false === $this->cases->contains($caseItem)) { | ||
$this->cases->add($caseItem); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param CaseItem $caseItem | ||
* @return HasCasesInterface | ||
*/ | ||
public function removeCase(CaseItem $caseItem) | ||
{ | ||
$this->initCases(); | ||
|
||
if (true == $this->cases->contains($caseItem)) { | ||
$this->cases->removeElement($caseItem); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
protected function initCases() | ||
{ | ||
if (null === $this->cases) { | ||
$this->cases = new ArrayCollection(); | ||
} | ||
} | ||
|
||
/** | ||
* Method to validate a person in the input filter, where required | ||
* This is a bitwise or comparison, if either condition is true, it returns true | ||
* @return bool | ||
* | ||
*/ | ||
public function hasAttachedCase() | ||
{ | ||
return (bool)($this->getCases()->count() > 0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.