Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
Merge branch 'release/1.1.31.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
brettminnie committed Dec 11, 2014
2 parents c66cd4c + 0b9631f commit 5336aa5
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 102 deletions.
23 changes: 16 additions & 7 deletions src/Opg/Common/Model/Entity/HasNotesInterface.php
Expand Up @@ -12,28 +12,37 @@ interface HasNotesInterface
{

/**
* @return ArrayCollection|null
* @return ArrayCollection
*/
public function getNotes();

/**
* @param ArrayCollection $notes
*
* @return ArrayCollection|null
* @return HasNotesInterface
*/
public function setNotes(ArrayCollection $notes);

/**
* @param NoteEntity $note
*
* @return $this
* @return HasNotesInterface
*/
public function addNote(NoteEntity $note);

/**
* @param ArrayCollection $notes
*
* @return $this
* @return HasNotesInterface
*/
public function addNotes(ArrayCollection $notes);

/**
* @param NoteEntity $note
* @return boolean
*/
public function hasNote(NoteEntity $note);

/**
* @param NoteEntity $note
* @return HasNotesInterface
*/
public function removeNote(NoteEntity $note);
}
57 changes: 45 additions & 12 deletions src/Opg/Common/Model/Entity/Traits/HasNotes.php
Expand Up @@ -2,6 +2,7 @@
namespace Opg\Common\Model\Entity\Traits;

use Doctrine\Common\Collections\ArrayCollection;
use Opg\Common\Model\Entity\HasNotesInterface;
use Opg\Core\Model\Entity\Note\Note as NoteEntity;
use Doctrine\ORM\Mapping as ORM;

Expand All @@ -28,41 +29,49 @@ trait HasNotes
* @Groups({"api-person-get"})
*/
protected $notes;


protected function initNotes()
{
if (null === $this->notes) {
$this->notes = new ArrayCollection();
}
}
/**
* @return ArrayCollection|null
* @return ArrayCollection
*/
public function getNotes()
{
$this->initNotes();

return $this->notes;
}

/**
* @param ArrayCollection $notes
*
* @return ArrayCollection|null
* @return HasNotesInterface
*/
public function setNotes(ArrayCollection $notes)
{
$this->notes = $notes;
$this->notes = new ArrayCollection();

foreach($notes as $note) {
$this->addNote($note);
}

return $this;
}

/**
* @param NoteEntity $note
*
* @return $this
* @return HasNotesInterface
*/
public function addNote(NoteEntity $note)
{
// @codeCoverageIgnoreStart
if (is_null($this->notes)) {
$this->notes = new ArrayCollection();
}
// @codeCoverageIgnoreEnd
$this->initNotes();

if (!$this->notes->contains($note)) {
if (false === $this->notes->contains($note)) {
$this->notes->add($note);
}

Expand All @@ -72,7 +81,7 @@ public function addNote(NoteEntity $note)
/**
* @param ArrayCollection $notes
*
* @return $this
* @return HasNotesInterface
*/
public function addNotes(ArrayCollection $notes)
{
Expand All @@ -82,4 +91,28 @@ public function addNotes(ArrayCollection $notes)

return $this;
}

/**
* @param NoteEntity $note
* @return bool
*/
public function hasNote(NoteEntity $note)
{
$this->initNotes();

return $this->notes->contains($note);
}

/**
* @param NoteEntity $note
* @return HasNotesInterface
*/
public function removeNote(NoteEntity $note)
{
if ($this->hasNote($note)) {
$this->notes->removeElement($note);
}

return $this;
}
}
2 changes: 1 addition & 1 deletion src/Opg/Core/Model/Entity/CaseItem/CaseItem.php
Expand Up @@ -47,7 +47,7 @@
* "dep" = "Opg\Core\Model\Entity\CaseItem\Deputyship\Deputyship",
* "order" = "Opg\Core\Model\Entity\CaseItem\Deputyship\Order",
* })
* @ORM\entity(repositoryClass="Application\Model\Repository\CaseRepository")
* @ORM\entity(repositoryClass="Application\Model\Repository\CaseItemRepository")
*/
abstract class CaseItem extends LegalEntity implements CaseItemInterface, HasRagRating, IsAssignable
{
Expand Down
11 changes: 1 addition & 10 deletions src/Opg/Core/Model/Entity/CaseItem/Deputyship/Deputyship.php
@@ -1,14 +1,10 @@
<?php
namespace Opg\Core\Model\Entity\CaseItem\Deputyship;

use Doctrine\Common\Collections\ArrayCollection;
use Opg\Common\Model\Entity\HasStatusDate;
use Opg\Common\Model\Entity\Traits\StatusDate;
use Opg\Common\Model\Entity\Traits\ToArray;
use Opg\Common\Model\Entity\Traits\InputFilter;
use Opg\Core\Model\Entity\CaseActor\Client;
use Opg\Core\Model\Entity\CaseActor\Decorators\CaseRecNumber;
use Opg\Core\Model\Entity\CaseActor\Donor;
use Opg\Core\Model\Entity\CaseActor\Interfaces\HasCaseRecNumber;
use Opg\Core\Model\Entity\CaseItem\CaseItem;
use Doctrine\ORM\Mapping as ORM;
Expand Down Expand Up @@ -215,12 +211,7 @@ public function hasSecurityBond()
*/
public function setClient(Client $client)
{
if (null === $this->client) {
$this->client = $client;
}
else {
throw new \LogicException('This case already has an attached client');
}
$this->client = $client;

return $this;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Opg/Core/Model/Entity/CaseItem/Deputyship/Order.php
Expand Up @@ -13,12 +13,20 @@
use Opg\Core\Model\Entity\CaseItem\Validation\InputFilter\OrderFilter;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\ReadOnly;
use Opg\Core\Model\Entity\CaseItem\Validation\Validator\CaseType as CaseTypeValidator;

/**
* @ORM\Entity
*/
class Order extends Deputyship implements HasCourtFundsInterface
{
/**
* @ORM\Column(type = "string", nullable = true)
* @var string
* @Groups("api-task-list")
*/
protected $caseType = CaseTypeValidator::CASE_TYPE_ORDER;

use HasCourtFunds;

/**
Expand Down
Expand Up @@ -28,7 +28,7 @@
* Class PowerOfAttorney
* @package Opg\Core\Model\Entity\CaseItem\PowerOfAttorney
*
* @ORM\Entity(repositoryClass="Application\Model\Repository\PowerOfAttorneyRepository")
* @ORM\Entity(repositoryClass="Application\Model\Repository\CaseItemRepository")
*
*/
abstract class PowerOfAttorney extends CaseItem implements HasNoticeGivenDate
Expand Down
Expand Up @@ -10,6 +10,8 @@ class OrderFilter extends BaseInputFilter
{
protected function setValidators()
{
$this->addValidator('orderStatus', 'Opg\Core\Model\Entity\CaseItem\Validation\Validator\OrderStatus');
$this->addValidator('orderStatus', 'Opg\Core\Model\Entity\CaseItem\Validation\Validator\OrderStatus');
$this->addValidator('caseSubtype', 'Opg\Core\Model\Entity\CaseItem\Validation\Validator\CaseSubtype');
$this->addValidator('caseType', 'Opg\Core\Model\Entity\CaseItem\Validation\Validator\CaseType');
}
}
@@ -1,7 +1,7 @@
<?php
namespace Opg\Core\Model\Entity\CaseItem\Validation\Validator;

use Opg\Core\Model\Entity\CaseItem\Lpa\Validator\CaseType as CaseTypeValidator;
use Opg\Core\Model\Entity\CaseItem\Validation\Validator\CaseType as CaseTypeValidator;
use Zend\Validator\Callback;

/**
Expand All @@ -24,10 +24,10 @@ function ($value, $context) {
// SubType validation is automatically successful if this isn't an LPA or EPA...
$caseTypesWhichRequireValidation = [
CaseTypeValidator::CASE_TYPE_EPA,
CaseTypeValidator::CASE_TYPE_LPA
CaseTypeValidator::CASE_TYPE_LPA,
CaseTypeValidator::CASE_TYPE_ORDER,
];

$caseType = $context->getCaseType();
$caseType = $context['caseType'];

if (!in_array($caseType, $caseTypesWhichRequireValidation)) {
return true;
Expand All @@ -49,6 +49,13 @@ function ($value, $context) {
];
break;

case CaseTypeValidator::CASE_TYPE_ORDER:
$validSubtypes = [
self::CASE_SUB_TYPE_HW,
self::CASE_SUB_TYPE_PFA
];
break;

default:
// Empty array means all values fail;
$validSubtypes = [];
Expand Down
Expand Up @@ -10,8 +10,9 @@
*/
class CaseType extends InArray
{
const CASE_TYPE_EPA = 'epa';
const CASE_TYPE_LPA = 'lpa';
const CASE_TYPE_EPA = 'EPA';
const CASE_TYPE_LPA = 'LPA';
const CASE_TYPE_ORDER = 'ORDER';

public function __construct()
{
Expand All @@ -21,6 +22,7 @@ public function __construct()
array(
self::CASE_TYPE_EPA,
self::CASE_TYPE_LPA,
self::CASE_TYPE_ORDER
)
);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Opg/Core/Model/Entity/Queue.php
Expand Up @@ -6,6 +6,9 @@
use DateTime;
use Opg\Common\Model\Entity\HasIdInterface;
use Opg\Common\Model\Entity\Traits\HasId;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Groups;

/**
* Queue
Expand Down
2 changes: 0 additions & 2 deletions src/Opg/Core/Model/Entity/Warning/Warning.php
Expand Up @@ -184,9 +184,7 @@ public function getDateAddedString()
return $this->getDateAdded()->format(DateFormat::getDateFormat());
}

// @codeCoverageIgnoreStart
return '';
//@codeCoverageIgnoreEnd
}

/**
Expand Down

0 comments on commit 5336aa5

Please sign in to comment.