Ejemplo n.º 1
0
 public function delete($id)
 {
     try {
         $modalidade = $this->find_by($id);
         $this->em->remove($modalidade);
     } catch (Exception $ex) {
         $this->CI->log->write_log('error', $ex->getMessage() . ' - modalidade_dao::delete ');
     }
 }
Ejemplo n.º 2
0
 public function delete($id)
 {
     try {
         $categoria = $this->find_by($id);
         $this->em->remove($categoria);
         return true;
     } catch (Exception $ex) {
         $this->CI->log->write_log('error', $ex->getMessage() . ' - categoria_dao::delete ');
     }
     return false;
 }
Ejemplo n.º 3
0
 public function down(Schema $schema)
 {
     $customers = $this->em->getRepository('Group3\\Bundle\\ABundle\\Entity\\Customer')->findAll();
     foreach ($customers as $customer) {
         $this->em->remove($customer);
     }
     $inventory = $this->em->getRepository('Group3\\Bundle\\ABundle\\Entity\\Inventory')->findAll();
     foreach ($inventory as $item) {
         $this->em->remove($item);
     }
     $this->em->flush();
 }
Ejemplo n.º 4
0
 public function delete($id)
 {
     try {
         $curso = $this->find_one_by($id);
         if ($curso) {
             $this->em->remove($curso);
             $this->em->flush();
         }
         return true;
     } catch (Exception $ex) {
         $this->CI->log->write_log('error', $ex->getMessage() . ' - curso_dao::delete ');
     }
     return false;
 }
 /**
  * Delete a message from the queue.
  *
  * Returns true if the message is deleted, false if the deletion is
  * unsuccessful.
  *
  * @param ZendQueue\Message $message
  *
  * @return bool
  *
  * @throws ZendQueue\Exception - database error
  */
 public function deleteMessage(Message $message)
 {
     $repo = $this->em->getRepository('Heri\\Bundle\\JobQueueBundle\\Entity\\Message')->findOneBy(['handle' => $message->handle]);
     $this->em->remove($repo);
     $this->em->flush();
     return $this->em->clear();
 }
Ejemplo n.º 6
0
 /**
  * Unset article-image rendition
  *
  * @param int $articleNumber
  * @param int $image
  * @return void
  */
 public function unsetArticleImageRenditions($articleNumber, $image)
 {
     $renditions = $this->orm->getRepository('Newscoop\\Image\\ArticleRendition')->findBy(array('articleNumber' => (int) $articleNumber, 'image' => (int) $image));
     foreach ($renditions as $one_rend) {
         $this->orm->remove($one_rend);
         $this->orm->flush();
     }
 }
Ejemplo n.º 7
0
 public function testDelete()
 {
     $user = $this->addUser();
     $id = $user->id;
     $user = $this->em->find('Admin\\Model\\User', $id);
     $this->em->remove($user);
     $this->em->flush();
     $user = $this->em->find('Admin\\Model\\User', $id);
     $this->assertNull($user);
 }
Ejemplo n.º 8
0
 /**
  * Upload image and create entity
  *
  * @param UploadedFile $file
  * @param array        $attributes
  *
  * @return Local
  */
 public function upload(UploadedFile $file, array $attributes)
 {
     $filesystem = new Filesystem();
     $imagine = new Imagine();
     $errors = array();
     $mimeType = $file->getClientMimeType();
     if (!in_array($mimeType, $this->supportedTypes)) {
         $errors[] = $this->translator->trans('ads.error.unsupportedType', array('%type%' => $mimeType));
     }
     if (!file_exists($this->config['image_path']) || !is_writable($this->config['image_path'])) {
         $errors[] = $this->translator->trans('ads.error.notwritable', array('%dir%' => $this->config['image_dir']));
     }
     if (!file_exists($this->config['thumbnail_path']) || !is_writable($this->config['thumbnail_path'])) {
         $errors[] = $this->translator->trans('ads.error.notwritable', array('%dir%' => $this->config['thumbnail_dir']));
     }
     if (!empty($errors)) {
         return $errors;
     }
     $attributes = array_merge(array('content_type' => $mimeType), $attributes);
     $image = new Image($file->getClientOriginalName());
     $this->orm->persist($image);
     $this->fillImage($image, $attributes);
     $this->orm->flush();
     $imagePath = $this->generateImagePath($image->getId(), $file->getClientOriginalExtension());
     $thumbnailPath = $this->generateThumbnailPath($image->getId(), $file->getClientOriginalExtension());
     $image->setBasename($this->generateImagePath($image->getId(), $file->getClientOriginalExtension(), true));
     $image->setThumbnailPath($this->generateThumbnailPath($image->getId(), $file->getClientOriginalExtension(), true));
     $this->orm->flush();
     try {
         $file->move($this->config['image_path'], $this->generateImagePath($image->getId(), $file->getClientOriginalExtension(), true));
         $filesystem->chmod($imagePath, 0644);
         $imagine->open($imagePath)->resize(new Box($this->config['thumbnail_max_size'], $this->config['thumbnail_max_size']))->save($thumbnailPath, array());
         $filesystem->chmod($thumbnailPath, 0644);
     } catch (\Exceptiom $e) {
         $filesystem->remove($imagePath);
         $filesystem->remove($thumbnailPath);
         $this->orm->remove($image);
         $this->orm->flush();
         return array($e->getMessage());
     }
     return $image;
 }
Ejemplo n.º 9
0
 /**
  * Delete package
  *
  * @param  int  $id
  * @return void
  */
 public function delete($id)
 {
     $package = $this->orm->getRepository('Newscoop\\Package\\Package')->find($id);
     $this->orm->remove($package);
     $this->orm->flush();
 }
Ejemplo n.º 10
0
 /**
  * Remove image from article
  *
  * @param ArticleImage $articleImage
  */
 public function removeArticleImage(ArticleImage $articleImage)
 {
     \ArticleImage::RemoveImageTagsFromArticleText($articleImage->getArticleNumber(), $articleImage->getNumber());
     $this->orm->remove($articleImage);
     $this->orm->flush();
 }
Ejemplo n.º 11
0
 /**
  * Delete subscription
  *
  * @param int $subscriptionId
  * @return void
  */
 public function delete($id)
 {
     $this->em->remove($this->repository->find((int) $id));
     $this->em->flush();
 }
Ejemplo n.º 12
0
 /**
  * Delete section
  *
  * @param int $id
  * @return void
  */
 public function delete($id)
 {
     $this->em->remove($this->em->getReference('Newscoop\\Subscription\\Section', $id));
     $this->em->flush();
 }
Ejemplo n.º 13
0
 /**
  * Remove the Entity from EntityManager.
  *
  * @param Core\Entity $object
  *
  * @return Core\Entity
  */
 public function remove($object)
 {
     $this->entityManager->remove($object);
     $this->entityManager->flush();
     return $object;
 }
Ejemplo n.º 14
0
 /**
  * Delete ip
  *
  * @param array $id
  * @return void
  */
 public function delete(array $id)
 {
     $id['ip'] = ip2long($id['ip']);
     $this->em->remove($this->repository->findOneBy($id));
     $this->em->flush();
 }