예제 #1
0
 /**
  * Deletes the footprint with the given id.
  * 
  * @param int $id The footprint id to delete
  * @throws \PartKeepr\Util\SerializableException
  */
 public function deleteFootprint($id)
 {
     $footprint = Footprint::loadById($id);
     try {
         PartKeepr::getEM()->remove($footprint);
         PartKeepr::getEM()->flush();
     } catch (\PDOException $e) {
         if ($e->getCode() == "23000") {
             $exception = new SerializableException(sprintf(PartKeepr::i18n("Footprint %s is in use by some parts!"), $footprint->getName()));
             $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the footprint %s, but there are parts which use this footprint."), $footprint->getName()));
             throw $exception;
         }
     }
 }
 public function create()
 {
     $this->requireParameter("name");
     $storageLocation = new StorageLocation();
     $storageLocation->deserialize($this->getParameters());
     PartKeepr::getEM()->persist($storageLocation);
     try {
         PartKeepr::getEM()->flush();
     } catch (\PDOException $e) {
         if ($e->getCode() == "23505") {
             $exception = new SerializableException(sprintf(PartKeepr::i18n("Storage Location %s already exists!"), $storageLocation->getName()));
             $exception->setDetail(sprintf(PartKeepr::i18n("You tried to add the storage location %s, but a storage location with the same name already exists."), $storageLocation->getName()));
             throw $exception;
         } else {
             throw $e;
         }
     }
     return array("data" => $storageLocation->serialize());
 }
예제 #3
0
 /**
  * Deletes the given category ID.
  * @param $id int The category id to delete
  * @throws CategoryNotFoundException If the category wasn't found
  */
 public function deleteCategory($id)
 {
     $category = $this->getCategory($id);
     try {
         if ($category->hasChildren()) {
             $exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains other categories."), $category->getNode()->getName()));
             $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains other categories. Please move the categories or delete them first."), $category->getNode()->getName()));
             throw $exception;
         }
         parent::deleteCategory($id);
     } catch (\PDOException $e) {
         if ($e->getCode() == "23000") {
             $exception = new SerializableException(sprintf(PartKeepr::i18n("Category '%s' contains parts."), $category->getNode()->getName()));
             $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the category '%s', but it still contains parts. Please move the parts to another category."), $category->getNode()->getName()));
             throw $exception;
         } else {
             throw $e;
         }
     }
 }
 public function __construct(User $user, $preferenceKey)
 {
     $message = sprintf(PartKeepr::i18n("User preference %s not found for user %s (%s)"), $preferenceKey, $user->getUsername(), $user->getId());
     parent::__construct($message);
 }
 public function __construct($detailedReason, $requestedClass, $availableClasses)
 {
     parent::__construct(PartKeepr::i18n("No adequate renderer found: {$detailedReason} \nRequested: {$requestedClass} \nAvailable: " . implode(", ", $availableClasses)));
 }
 public function __construct()
 {
     parent::__construct("The entity is not persistant.");
 }
 public function __construct($class, $id)
 {
     parent::__construct(sprintf(PartKeepr::i18n("The object of type %s with the id %s could not be found in the database."), $class, $id));
 }
 public function __construct()
 {
     parent::__construct(PartKeepr::i18n("Storage Location not found."));
 }
 public function __construct($username)
 {
     parent::__construct(sprintf(PartKeepr::i18n("User %s already exists."), $username));
 }
 public function __construct($id)
 {
     parent::__construct(sprintf(PartKeepr::i18n("Category %d not found."), $id));
 }
 public function __construct($username)
 {
     parent::__construct(sprintf(PartKeepr::i18n("The user %s doesn't exist. Maybe the user was already deleted."), $username));
 }
 /**
  * Constructs the exception
  * @param BaseEntity $entity
  */
 public function __construct(Part $part)
 {
     parent::__construct(PartKeepr::i18n("Part %s has no category assigned", $part));
 }
 public function __construct()
 {
     parent::__construct(PartKeepr::i18n("Username or Password wrong."));
 }
 public function __construct($class, $id)
 {
     parent::__construct(sprintf(PartKeepr::i18n("The entity %s with the id %d could not be found"), $class, $id));
 }
 public function __construct($id)
 {
     parent::__construct("The session with the id {$id} could not be found");
 }
 public function __construct($detailedReason)
 {
     parent::__construct($detailedReason);
 }
 /**
  * Constructs the exception
  * @param BaseEntity $entity
  */
 public function __construct()
 {
     parent::__construct(PartKeepr::i18n("No storage location assigned"));
 }