Example #1
0
 /**
  * Removes a category by its associated id (Including images if present)
  * 
  * @param string $id
  * @return boolean
  */
 private function removeCategoryById($id)
 {
     $this->removeWebPageById($id);
     $this->categoryMapper->deleteById($id);
     $this->imageManager->delete($id);
     return true;
 }
Example #2
0
 /**
  * Removes a product by its associated id
  * 
  * @param string $id Product id
  * @return boolean
  */
 private function removeById($id)
 {
     // Remove from a storage first
     $this->productMapper->deleteById($id);
     $this->imageMapper->deleteAllByProductId($id);
     // Now remove from the file-system
     $this->imageManager->delete($id);
     return true;
 }
Example #3
0
 /**
  * Removes all post images associated with category id
  * 
  * @param string $id Category's id
  * @return boolean
  */
 private function removeAllPostImagesByCategoryId($id)
 {
     $ids = $this->postMapper->fetchAllIdsWithImagesByCategoryId($id);
     // Do the work, in case there's at least one id
     if (!empty($ids)) {
         foreach ($ids as $id) {
             $this->imageManager->delete($id);
         }
     }
     return true;
 }
Example #4
0
 /**
  * Fetches basic product info by its associated id
  * 
  * @param string $id Product id
  * @return \Shop\Service\ProductEntity|boolean
  */
 public function fetchBasicById($id)
 {
     $product = $this->productMapper->fetchBasicById($id);
     // If not empty, then valid $id supplied
     if (!empty($product)) {
         $imageBag = clone $this->imageManager->getImageBag();
         $imageBag->setId($id)->setCover($product['cover']);
         $entity = new ProductEntity();
         $entity->setId($id)->setImageBag($imageBag)->setCover($product['cover'], ProductEntity::FILTER_TAGS)->setName($product['name'], ProductEntity::FILTER_TAGS)->setInStock($product['in_stock'], ProductEntity::FILTER_INT)->setRegularPrice($product['regular_price'], ProductEntity::FILTER_FLOAT)->setStokePrice($product['stoke_price'], ProductEntity::FILTER_FLOAT);
         return $entity;
     } else {
         return false;
     }
 }
Example #5
0
 /**
  * Deletes a member
  * 
  * @param string $id Member's id
  * @return boolean
  */
 private function delete($id)
 {
     return $this->teamMapper->deleteById($id) && $this->imageManager->delete($id);
 }