partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 99e5a3fe7b31cbf544204eb3dd4dd33b41bf5f92
parent 0cc44c6d00426f12a683f04b79a033255c9e38e9
Author: Timo A. Hummel <felicitus@felicitus.org>
Date:   Fri,  6 Nov 2015 23:41:59 +0100

Removed legacy exceptions and replaced them with new ones

Diffstat:
Msrc/PartKeepr/PartBundle/Entity/Part.php | 5++---
Msrc/PartKeepr/PartBundle/Entity/PartDistributor.php | 5++---
Asrc/PartKeepr/PartBundle/Exceptions/MinStockLevelOutOfRangeException.php | 13+++++++++++++
Asrc/PartKeepr/PartBundle/Exceptions/PackagingUnitOutOfRangeException.php | 13+++++++++++++
4 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/PartKeepr/PartBundle/Entity/Part.php b/src/PartKeepr/PartBundle/Entity/Part.php @@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM; use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; use PartKeepr\FootprintBundle\Entity\Footprint; use PartKeepr\PartBundle\Exceptions\CategoryNotAssignedException; +use PartKeepr\PartBundle\Exceptions\MinStockLevelOutOfRangeException; use PartKeepr\PartBundle\Exceptions\StorageLocationNotAssignedException; use PartKeepr\PartKeepr; use PartKeepr\ProjectBundle\Entity\ProjectPart; @@ -631,9 +632,7 @@ class Part extends BaseEntity $minStockLevel = intval($minStockLevel); if ($minStockLevel < 0) { - $exception = new OutOfRangeException(PartKeepr::i18n("Minimum Stock Level is out of range")); - $exception->setDetail(PartKeepr::i18n("The minimum stock level must be 0 or higher")); - throw $exception; + throw new MinStockLevelOutOfRangeException(); } $this->minStockLevel = $minStockLevel; } diff --git a/src/PartKeepr/PartBundle/Entity/PartDistributor.php b/src/PartKeepr/PartBundle/Entity/PartDistributor.php @@ -3,6 +3,7 @@ namespace PartKeepr\PartBundle\Entity; use Doctrine\ORM\Mapping as ORM; use PartKeepr\DistributorBundle\Entity\Distributor; +use PartKeepr\PartBundle\Exceptions\PackagingUnitOutOfRangeException; use PartKeepr\PartKeepr; use PartKeepr\Util\BaseEntity; use PartKeepr\Util\Exceptions\OutOfRangeException; @@ -89,9 +90,7 @@ class PartDistributor extends BaseEntity $packagingUnit = intval($packagingUnit); if ($packagingUnit < 1) { - $exception = new OutOfRangeException(PartKeepr::i18n("Packaging Unit is out of range")); - $exception->setDetail(PartKeepr::i18n("The packaging unit must be 1 or higher")); - throw $exception; + throw new PackagingUnitOutOfRangeException(); } $this->packagingUnit = $packagingUnit; diff --git a/src/PartKeepr/PartBundle/Exceptions/MinStockLevelOutOfRangeException.php b/src/PartKeepr/PartBundle/Exceptions/MinStockLevelOutOfRangeException.php @@ -0,0 +1,12 @@ +<?php +namespace PartKeepr\PartBundle\Exceptions; + +use PartKeepr\CoreBundle\Exceptions\TranslatableException; + +class MinStockLevelOutOfRangeException extends TranslatableException +{ + public function getMessageKey() + { + return "Minimum Stock Level is out of range. The minimum stock level must be 0 or higher"; + } +}+ \ No newline at end of file diff --git a/src/PartKeepr/PartBundle/Exceptions/PackagingUnitOutOfRangeException.php b/src/PartKeepr/PartBundle/Exceptions/PackagingUnitOutOfRangeException.php @@ -0,0 +1,12 @@ +<?php +namespace PartKeepr\PartBundle\Exceptions; + +use PartKeepr\CoreBundle\Exceptions\TranslatableException; + +class PackagingUnitOutOfRangeException extends TranslatableException +{ + public function getMessageKey() + { + return "Packaging Unit is out of range. It must be 1 or higher."; + } +}+ \ No newline at end of file