commit 124e9783453cdb1d9c2362f8843f53ed55acbecc
parent c70159d0f3938ad0440714de2160c8041384b8de
Author: Felicitus <felicitus@felicitus.org>
Date: Tue, 3 Apr 2012 06:11:09 +0200
Refer to the part when throwing the CategoryNotAssignedException
Diffstat:
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Part/Exceptions/CategoryNotAssignedException.php b/src/backend/de/RaumZeitLabor/PartKeepr/Part/Exceptions/CategoryNotAssignedException.php
@@ -2,7 +2,8 @@
namespace de\RaumZeitLabor\PartKeepr\Part\Exceptions;
use de\RaumZeitLabor\PartKeepr\PartKeepr,
- de\RaumZeitLabor\PartKeepr\Util\SerializableException;
+ de\RaumZeitLabor\PartKeepr\Util\SerializableException,
+ de\RaumZeitLabor\PartKeepr\Part\Part;
/**
* This exception is thrown when a part hasn't got a category assigned
@@ -13,7 +14,7 @@ class CategoryNotAssignedException extends SerializableException {
* Constructs the exception
* @param BaseEntity $entity
*/
- public function __construct () {
- parent::__construct(PartKeepr::i18n("No category assigned"));
+ public function __construct (Part $part) {
+ parent::__construct(PartKeepr::i18n("Part %s has no category assigned", $part));
}
}
\ No newline at end of file
diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Part/Part.php b/src/backend/de/RaumZeitLabor/PartKeepr/Part/Part.php
@@ -516,7 +516,7 @@ class Part extends BaseEntity implements Serializable, Deserializable {
*/
private function checkCategoryConsistency () {
if ($this->getCategory() === null) {
- throw new CategoryNotAssignedException();
+ throw new CategoryNotAssignedException($this);
}
}
@@ -557,4 +557,14 @@ class Part extends BaseEntity implements Serializable, Deserializable {
$this->checkStorageLocationConsistency();
}
+ /**
+ * Returns a string representation of the part
+ *
+ * @param none
+ * @return string The name and the ID of the part
+ */
+ public function __toString () {
+ return $this->getName() . " (".$this->getId().")";
+ }
+
}