/** * @Route("/delete/{id}/") * @ParamConverter("get") * @Template() */ public function deleteAction(Request $request, Entry $entry) { if ($entry->getArticleId() !== null) { $publisherService = $this->container->get('newscoop_ingest_plugin.publisher'); $publisherService->remove($entry); } $em = $this->container->get('em'); $em->remove($entry); $em->flush(); $this->get('session')->getFlashBag()->add('notice', $this->container->get('translator')->trans('plugin.ingest.entries.removedsuccess')); return $this->redirect($this->generateUrl('newscoop_ingestplugin_entry_list')); }
/** * Set images for the article * * @param \Article $article * @param \Newscoop\IngestPluginBundle\Entity\Entry $entry */ protected function setArticleImagesLegacy(\Article $article, \Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry) { $images = $entry->getImages(); if (!is_array($images) || empty($images)) { return; } $oldImages = \ArticleImage::GetImagesByArticleNumber($article->getArticleNumber()); if (is_array($oldImages)) { foreach ($oldImages as $image) { $image->delete(); } } $filesystem = new Filesystem(); foreach ($images as $image) { if (!array_key_exists('location', $image) || !$image['location']) { continue; } $imagePath = ''; if ($filesystem->exists($image['location'])) { $basename = basename($image['location']); $imagePath = $image['location']; } else { $tmpPath = tempnam(sys_get_temp_dir(), 'NWSIMG'); try { $filesystem->copy($image['location'], $tmpPath, true); } catch (IOExceptionInterface $e) { continue; } $imagePath = $tmpPath; $basename = basename($image['location']); } $imagesize = getimagesize($imagePath); $info = array('name' => $basename, 'type' => $imagesize['mime'], 'tmp_name' => $imagePath, 'size' => filesize($imagePath), 'error' => 0); $attributes = array('Photographer' => array_key_exists('photographer', $image) ? $image['photographer'] : '', 'Description' => array_key_exists('description', $image) ? $image['description'] : '', 'Source' => 'newsfeed', 'Status' => 'approved'); try { $image = \Image::OnImageUpload($info, $attributes, null, null, true); \ArticleImage::AddImageToArticle($image->getImageId(), $article->getArticleNumber(), null); } catch (\Exception $e) { var_dump($e); exit; } } }