Group FEWO | Upload Image FEWO | POS
Gruppen für die FEWO Upload Images bei den Gruppen + vor und nach Pos Sortierungen bei den Images Einbau in den Frontend Silder Bilder zuweisen pre + page + post git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3367 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
ff986cd437
commit
1293c19bc6
25 changed files with 1249 additions and 37 deletions
|
|
@ -10,16 +10,20 @@ namespace AppBundle\Controller;
|
|||
use AppBundle\AppBundle;
|
||||
use AppBundle\Entity\FewoBookingRequest;
|
||||
use AppBundle\Entity\FewoLodging;
|
||||
use AppBundle\Entity\FewoLodgingGroup;
|
||||
use AppBundle\Entity\FewoPrice;
|
||||
use AppBundle\Entity\FewoReservation;
|
||||
use AppBundle\Entity\FewoSeason;
|
||||
use AppBundle\Entity\FewoLodgingImage;
|
||||
use AppBundle\Entity\FewoLodgingGroupImage;
|
||||
use AppBundle\Form\FewoBookingRequestType;
|
||||
use AppBundle\Form\FewoLodgingType;
|
||||
use AppBundle\Form\FewoLodgingTypeGroup;
|
||||
use AppBundle\Form\FewoPriceType;
|
||||
use AppBundle\Form\FewoReservationType;
|
||||
use AppBundle\Form\FewoSeasonType;
|
||||
use AppBundle\Form\FewoLodgingImageType;
|
||||
use AppBundle\Form\FewoLodgingGroupImageType;
|
||||
use AppBundle\Service\FileManager;
|
||||
use AppBundle\Util;
|
||||
use Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\FileSystemCacheTest;
|
||||
|
|
@ -73,12 +77,12 @@ class AdminController extends Controller
|
|||
*/
|
||||
public function adminFewoLodgingsAction(Request $request)
|
||||
{
|
||||
$fewoLodgingRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodging');
|
||||
|
||||
$lodgings = $fewoLodgingRepo->findAll();
|
||||
|
||||
$fewoLodgingGroupRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodgingGroup');
|
||||
$lodgingGroups = $fewoLodgingGroupRepo->findAll();
|
||||
|
||||
return $this->render('default/admin/lodgings.html.twig', [
|
||||
'lodgings' => $lodgings,
|
||||
'lodgingGroups' => $lodgingGroups,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +92,6 @@ class AdminController extends Controller
|
|||
public function adminFewoNewLodgingAction(Request $request)
|
||||
{
|
||||
$lodging = null;
|
||||
|
||||
if ($request->getMethod() != 'POST')
|
||||
{
|
||||
$lodging = new FewoLodging();
|
||||
|
|
@ -120,6 +123,85 @@ class AdminController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Route("/admin/fewo/lodgings/group/new")
|
||||
*/
|
||||
public function adminFewoGroupNewLodgingAction(Request $request)
|
||||
{
|
||||
$lodgingGroup = null;
|
||||
if ($request->getMethod() != 'POST')
|
||||
{
|
||||
$lodgingGroup = new FewoLodgingGroup();
|
||||
}
|
||||
|
||||
$form = $this->createForm(FewoLodgingTypeGroup::class, $lodgingGroup, [
|
||||
|
||||
]);
|
||||
|
||||
|
||||
// todo if(form == null)...
|
||||
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
$form->handleRequest($request);
|
||||
$lodgingGroup = $form->getData();
|
||||
}
|
||||
|
||||
|
||||
if ($request->getMethod() == 'POST' && $form->isValid())
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$em->persist($lodgingGroup);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect('/admin/fewo/lodgings');
|
||||
}
|
||||
return $this->render('default/admin/lodgingsGroupNew.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/admin/fewo/lodging/group/{lodgingGroupId}", requirements={"lodgingGroupId": "\d+"})
|
||||
*/
|
||||
public function adminFewoEditLodgingGroupAction(Request $request, $lodgingGroupId)
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$fewoLodgingGroupRepo = $em->getRepository('AppBundle:FewoLodgingGroup');
|
||||
|
||||
$lodgingGroup = null;
|
||||
|
||||
|
||||
$lodgingGroup = $fewoLodgingGroupRepo->find($lodgingGroupId);
|
||||
|
||||
|
||||
$form = $this->createForm(FewoLodgingTypeGroup::class, $lodgingGroup, [
|
||||
//options
|
||||
]);
|
||||
|
||||
if($request->getMethod() == 'POST')
|
||||
{
|
||||
$form->handleRequest($request);
|
||||
}
|
||||
|
||||
|
||||
if ($request->getMethod() == 'POST' && $form->isValid())
|
||||
{
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect('/admin/fewo/lodgings');
|
||||
}
|
||||
|
||||
|
||||
return $this->render('default/admin/lodgingGroupEdit.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'lodgingGroup' => $lodgingGroup,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function getSeasons(FewoLodging $lodging)
|
||||
{
|
||||
$seasons = [];
|
||||
|
|
@ -222,6 +304,25 @@ class AdminController extends Controller
|
|||
return $this->redirect('/admin/fewo/lodgings');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/admin/fewo/lodging/group/{lodgingGroupId}/delete", requirements={"lodgingGroupId": "\d+"})
|
||||
*/
|
||||
public function adminFewoDeleteLodgingGroupAction(Request $request, $lodgingGroupId)
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$fewoLodgingGroupRepo = $em->getRepository('AppBundle:FewoLodgingGroup');
|
||||
|
||||
$lodgingGroup = $fewoLodgingGroupRepo->find($lodgingGroupId);
|
||||
|
||||
if($lodgingGroup != null)
|
||||
{
|
||||
$em->remove($lodgingGroup);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirect('/admin/fewo/lodgings');
|
||||
}
|
||||
|
||||
|
||||
// todo, WEG
|
||||
/**
|
||||
|
|
@ -770,6 +871,8 @@ class AdminController extends Controller
|
|||
|
||||
return $this->redirect('/admin/fewo/seasons');
|
||||
}
|
||||
/* ---- FILES LODGING ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- */
|
||||
/* ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- */
|
||||
|
||||
/**
|
||||
* @Route("/admin/fewo/lodgings/{lodgingId}/images/multi-upload", requirements={"lodgingId": "\d+"})
|
||||
|
|
@ -794,9 +897,11 @@ class AdminController extends Controller
|
|||
$uploader = $this->container->get('app.image_uploader');
|
||||
foreach ($form->getData() as $uploadedFile)
|
||||
{
|
||||
|
||||
$image = new FewoLodgingImage();
|
||||
$image->setFile($uploadedFile);
|
||||
$image->setLodging($lodging);
|
||||
$image->setPos(0);
|
||||
$image->setFileName('');
|
||||
$image->setDescription('');
|
||||
$em->persist($image);
|
||||
|
|
@ -865,6 +970,7 @@ class AdminController extends Controller
|
|||
if ($request->getMethod() != 'POST' && $image == null)
|
||||
{
|
||||
$image = new FewoLodgingImage();
|
||||
$image->setPos(0);
|
||||
}
|
||||
|
||||
$form = $this->createForm(FewoLodgingImageType::class, $image);
|
||||
|
|
@ -919,4 +1025,169 @@ class AdminController extends Controller
|
|||
|
||||
return $this->redirect('/admin/fewo/lodgings/'.$lodgingId);
|
||||
}
|
||||
|
||||
/* ---- FILES GROUP ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- */
|
||||
/* ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- */
|
||||
|
||||
/**
|
||||
* @Route("/admin/fewo/lodgings/group/{comp}/{lodgingGroupId}/images/multi-upload", requirements={"comp": "pre|post", "lodgingGroupId": "\d+"})
|
||||
*/
|
||||
public function adminFewoGroupImageMultiUploadAction(Request $request, $comp, $lodgingGroupId)
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$lodgingGroup = $em->getRepository('AppBundle:FewoLodgingGroup')->find($lodgingGroupId);
|
||||
if (!$lodgingGroup)
|
||||
{
|
||||
throw new HttpException(404, 'Unbekannte lodgingGroup-ID: '. $lodgingGroupId);
|
||||
}
|
||||
|
||||
$form = $this->createForm(FileType::class, null, [
|
||||
'multiple' => true
|
||||
]);
|
||||
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
|
||||
$form->handleRequest($request);
|
||||
if ($form->isValid())
|
||||
{
|
||||
$uploader = $this->container->get('app.image_uploader');
|
||||
foreach ($form->getData() as $uploadedFile)
|
||||
{
|
||||
|
||||
$image = new FewoLodgingGroupImage();
|
||||
$image->setFile($uploadedFile);
|
||||
$image->setLodgingGroup($lodgingGroup);
|
||||
$image->setComp($comp);
|
||||
$image->setPos(0);
|
||||
$image->setFileName('');
|
||||
$image->setDescription('');
|
||||
$em->persist($image);
|
||||
$em->flush();
|
||||
}
|
||||
return $this->redirect('/admin/fewo/lodging/group/'. $lodgingGroup->getId());
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('default/admin/fewoGroupImageMultiUpload.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'lodgingGroup' => $lodgingGroup,
|
||||
'comp' => $comp,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/admin/fewo/lodgings/group/{comp}/{lodgingGroupId}/images/new", requirements={"comp": "pre|post", "lodgingGroupId": "\d+"})
|
||||
*/
|
||||
public function adminFewoGroupNewImageAction(Request $request, $comp, $lodgingGroupId)
|
||||
{
|
||||
$lodgingGroup = $this->getEntityManager()->getRepository('AppBundle:FewoLodgingGroup')->find($lodgingGroupId);
|
||||
if (!$lodgingGroup)
|
||||
{
|
||||
throw new HttpException(404, 'Unbekannte lodgingGroup-ID: '. $lodgingGroupId);
|
||||
}
|
||||
return $this->processGroupImageForm($request, null, $comp, $lodgingGroup);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/admin/fewo/lodgings/group/{lodgingGroupId}/images/{imageId}", requirements={"lodgingGroupId": "\d+", "imageId": "\d+"})
|
||||
*/
|
||||
public function adminFewoGroupEditImageAction(Request $request, $lodgingGroupId, $imageId)
|
||||
{
|
||||
|
||||
/** @var FewoLodgingGroupImage $image */
|
||||
$image = $this->getEntityManager()->getRepository('AppBundle:FewoLodgingGroupImage')->find($imageId);
|
||||
if (!$image || $image->getLodgingGroup()->getId() != $lodgingGroupId)
|
||||
{
|
||||
throw new HttpException(404, 'Unbekannte FewoLodgingGroupImage-ID oder lodgingGroup-ID passt nicht: '.
|
||||
$imageId .' / '. $lodgingGroupId);
|
||||
}
|
||||
return $this->processGroupImageForm($request, $image);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FewoLodgingGroupImage $image
|
||||
* @param FewoLodgingGroup|null $lodgingGroup
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function processGroupImageForm(Request $request, $image, $comp = null, $lodgingGroup = null)
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
if ($image == null)
|
||||
{
|
||||
$isNew = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$isNew = false;
|
||||
$lodgingGroup = $image->getLodgingGroup();
|
||||
$imageFileName = $image->getFile();
|
||||
}
|
||||
|
||||
if ($request->getMethod() != 'POST' && $image == null)
|
||||
{
|
||||
$image = new FewoLodgingGroupImage();
|
||||
$image->setComp($comp);
|
||||
$image->setPos(0);
|
||||
}
|
||||
|
||||
$form = $this->createForm(FewoLodgingGroupImageType::class, $image);
|
||||
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
$form->handleRequest($request);
|
||||
}
|
||||
|
||||
|
||||
if ($request->getMethod() == 'POST' && $form->isValid())
|
||||
{
|
||||
$image = $form->getData();
|
||||
if ($isNew)
|
||||
{
|
||||
$image->setLodgingGroup($lodgingGroup);
|
||||
$image->setComp($comp);
|
||||
}
|
||||
else
|
||||
{
|
||||
$image->setFile($imageFileName);
|
||||
}
|
||||
$em->persist($image);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect('/admin/fewo/lodging/group/'. ($lodgingGroup->getId()));
|
||||
}
|
||||
|
||||
return $this->render('default/admin/fewoGroupImage.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'lodgingGroup' => $lodgingGroup,
|
||||
'is_new' => $isNew,
|
||||
'image_file_name' => $isNew ? null : $imageFileName,
|
||||
'image' => $image,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/admin/fewo/lodgings/group/{lodgingGroupId}/images/{imageId}/delete", requirements={"lodgingGroupId": "\d+", "imageId": "\d+"})
|
||||
*/
|
||||
public function adminFewoGroupDeleteImageAction(Request $request, $lodgingGroupId, $imageId)
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$fewoLodgingGroupImageRepo = $em->getRepository('AppBundle:FewoLodgingGroupImage');
|
||||
|
||||
$image = $fewoLodgingGroupImageRepo->find($imageId);
|
||||
|
||||
if($image != null)
|
||||
{
|
||||
$em->remove($image);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirect('/admin/fewo/lodging/group/'.$lodgingGroupId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ namespace AppBundle\Controller;
|
|||
|
||||
use AppBundle\Entity\Page;
|
||||
use AppBundle\Entity\SunstarTravelProgram;
|
||||
use AppBundle\Entity\FewoLodgingGroup;
|
||||
use AppBundle\Form\TtSearchRequestType;
|
||||
use AppBundle\Listener\KernelControllerListener;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
|
@ -55,9 +56,14 @@ class CmsController extends Controller
|
|||
$settings = [];
|
||||
}
|
||||
|
||||
$fewoLodgingGroupRepo = $this->getEntityManager()->getRepository('AppBundle:FewoLodgingGroup');
|
||||
$lodgingGroups = $fewoLodgingGroupRepo->findAll();
|
||||
|
||||
|
||||
return $this->render('default/pages/cms/overview.html.twig', array_merge($settings, [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'page' => $page,
|
||||
'lodgingGroups' => $lodgingGroups,
|
||||
]));
|
||||
}
|
||||
|
||||
|
|
@ -143,10 +149,29 @@ class CmsController extends Controller
|
|||
$calendar = $paddedCalendar;
|
||||
}
|
||||
|
||||
$imgs = array();
|
||||
$imgs_pre = array();
|
||||
$imgs_post = array();
|
||||
|
||||
$lodgingGroup = $lodging->getGroup();
|
||||
foreach ($lodgingGroup->getImages() as $image) {
|
||||
if($image->getComp() == 'pre'){
|
||||
$imgs_pre[] = $image;
|
||||
}
|
||||
if($image->getComp() == 'post'){
|
||||
$imgs_post[] = $image;
|
||||
}
|
||||
}
|
||||
foreach ($lodging->getImages() as $image) {
|
||||
$imgs[] = $image;
|
||||
}
|
||||
|
||||
|
||||
return $this->render('default/pages/cms/fewoTravelProgram.html.twig', [
|
||||
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
||||
'page' => $page,
|
||||
'fewo_lodging' => $lodging,
|
||||
'slider_imgs' => array_merge ($imgs_pre, $imgs, $imgs_post),
|
||||
//'lodging' => $lodging, //so wurde es im AdminController aufgerufen
|
||||
'calendar' => $calendar,
|
||||
'show_search_sidebar_widget' => false,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,16 @@ class FewoLodging
|
|||
private $name;
|
||||
|
||||
/**
|
||||
* @var \AppBundle\Entity\FewoLodgingGroup
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="FewoLodgingGroup")
|
||||
* @ORM\JoinColumns({
|
||||
* @ORM\JoinColumn(name="group_id", referencedColumnName="id")
|
||||
* })
|
||||
*/
|
||||
private $group;
|
||||
|
||||
/**
|
||||
* @var \AppBundle\Entity\FewoLodgingType
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="FewoLodgingType")
|
||||
|
|
@ -119,6 +129,7 @@ class FewoLodging
|
|||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="FewoLodgingImage", mappedBy="lodging", cascade={"persist", "remove"})
|
||||
* @ORM\OrderBy({"pos" = "ASC"})
|
||||
*/
|
||||
private $images;
|
||||
|
||||
|
|
@ -428,6 +439,31 @@ class FewoLodging
|
|||
return $this->calendarVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set type
|
||||
*
|
||||
* @param \AppBundle\Entity\FewoLodgingGroup $group
|
||||
*
|
||||
* @return FewoLodging
|
||||
*/
|
||||
public function setGroup(\AppBundle\Entity\FewoLodgingGroup $group = null)
|
||||
{
|
||||
$this->group = $group;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type
|
||||
*
|
||||
* @return \AppBundle\Entity\FewoLodgingGroup
|
||||
*/
|
||||
public function getGroup()
|
||||
{
|
||||
return $this->group;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set type
|
||||
*
|
||||
|
|
|
|||
141
trunk/src/AppBundle/Entity/FewoLodgingGroup.php
Normal file
141
trunk/src/AppBundle/Entity/FewoLodgingGroup.php
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Entity;
|
||||
|
||||
use AppBundle\AppBundle;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Table
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class FewoLodgingGroup
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="name", type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="FewoLodging", mappedBy="group", cascade={"persist", "remove"})
|
||||
*/
|
||||
private $lodgings;
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Bilder
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="FewoLodgingGroupImage", mappedBy="lodgingGroup", cascade={"persist", "remove"})
|
||||
* @ORM\OrderBy({"pos" = "ASC"})
|
||||
*/
|
||||
private $images;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->images = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lodgings
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
public function getLodgings()
|
||||
{
|
||||
return $this->lodgings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add image
|
||||
*
|
||||
* @param \AppBundle\Entity\FewoLodgingGroupImage $image
|
||||
*
|
||||
* @return FewoLodging
|
||||
*/
|
||||
public function addImage(\AppBundle\Entity\FewoLodgingGroupImage $image)
|
||||
{
|
||||
$this->images[] = $image;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove image
|
||||
*
|
||||
* @param \AppBundle\Entity\FewoLodgingGroupImage $image
|
||||
*/
|
||||
public function removeImage(\AppBundle\Entity\FewoLodgingGroupImage $image)
|
||||
{
|
||||
$this->images->removeElement($image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get images
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
public function getImages()
|
||||
{
|
||||
return $this->images;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return FewoLodgingType
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
function __toString()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
234
trunk/src/AppBundle/Entity/FewoLodgingGroupImage.php
Normal file
234
trunk/src/AppBundle/Entity/FewoLodgingGroupImage.php
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Entity;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Table
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class FewoLodgingGroupImage
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="full_file_name", type="string", length=255, nullable=false)
|
||||
* @Assert\Image(maxSize="15000000", mimeTypes={"image/jpeg", "image/png"})
|
||||
*/
|
||||
private $file;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="file_name", type="string", length=255, nullable=false)
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $fileName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="comp", type="string", length=4, nullable=true)
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $comp;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="pos", type="integer", nullable=false)
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $pos;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="description", type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @var \AppBundle\Entity\FewoLodgingGroup
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="FewoLodgingGroup", inversedBy="images")
|
||||
* @ORM\JoinColumns({
|
||||
* @ORM\JoinColumn(name="group_id", referencedColumnName="id", onDelete="SET NULL")
|
||||
* })
|
||||
*/
|
||||
private $lodgingGroup;
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set file
|
||||
*
|
||||
* @param string $file
|
||||
*
|
||||
* @return FewoLodgingGroupImage
|
||||
*/
|
||||
public function setFile($file)
|
||||
{
|
||||
$this->file = $file;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFile()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set description
|
||||
*
|
||||
* @param string $description
|
||||
*
|
||||
* @return FewoLodgingGroupImage
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set comp
|
||||
*
|
||||
* @param string $comp
|
||||
*
|
||||
* @return FewoLodgingGroupImage
|
||||
*/
|
||||
public function setComp($comp)
|
||||
{
|
||||
$this->comp = $comp;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comp
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getComp()
|
||||
{
|
||||
return $this->comp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set pos
|
||||
*
|
||||
* @param string $pos
|
||||
*
|
||||
* @return FewoLodgingGroupImage
|
||||
*/
|
||||
public function setPos($pos)
|
||||
{
|
||||
$this->pos = $pos;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pos
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPos()
|
||||
{
|
||||
return $this->pos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set lodgingGroup
|
||||
*
|
||||
* @param \AppBundle\Entity\FewoLodgingGroup $lodgingGroup
|
||||
*
|
||||
* @return FewoLodgingGroupImage
|
||||
*/
|
||||
public function setLodgingGroup(\AppBundle\Entity\FewoLodgingGroup $lodgingGroup = null)
|
||||
{
|
||||
$this->lodgingGroup = $lodgingGroup;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lodgingGroup
|
||||
*
|
||||
* @return \AppBundle\Entity\FewoLodgingGroup
|
||||
*/
|
||||
public function getLodgingGroup()
|
||||
{
|
||||
return $this->lodgingGroup;
|
||||
}
|
||||
|
||||
function __toString()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fileName
|
||||
*
|
||||
* @param string $fileName
|
||||
*
|
||||
* @return FewoLodgingGroupImage
|
||||
*/
|
||||
public function setFileName($fileName)
|
||||
{
|
||||
$this->fileName = $fileName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fileName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName()
|
||||
{
|
||||
return $this->fileName;
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,14 @@ class FewoLodgingImage
|
|||
*/
|
||||
private $fileName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="pos", type="integer", nullable=false)
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $pos;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
|
|
@ -88,6 +96,31 @@ class FewoLodgingImage
|
|||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pos
|
||||
*
|
||||
* @param string $pos
|
||||
*
|
||||
* @return FewoLodgingImage
|
||||
*/
|
||||
public function setPos($pos)
|
||||
{
|
||||
$this->pos = $pos;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pos
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPos()
|
||||
{
|
||||
return $this->pos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set description
|
||||
*
|
||||
|
|
|
|||
49
trunk/src/AppBundle/Form/FewoLodgingGroupImageType.php
Normal file
49
trunk/src/AppBundle/Form/FewoLodgingGroupImageType.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
class FewoLodgingGroupImageType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('file', FileType::class, [
|
||||
'data_class' => null
|
||||
])
|
||||
->add('pos')
|
||||
->add('comp', HiddenType::class, ['required' => false])
|
||||
->add('fileName')
|
||||
->add('description')
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'AppBundle\Entity\FewoLodgingGroupImage'
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'appbundle_fewolodginggroupimage';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ class FewoLodgingImageType extends AbstractType
|
|||
->add('file', FileType::class, [
|
||||
'data_class' => null
|
||||
])
|
||||
->add('pos')
|
||||
->add('fileName')
|
||||
->add('description')
|
||||
;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,14 @@ class FewoLodgingType extends AbstractType
|
|||
'required' => true,
|
||||
])
|
||||
//->add('calendarVisible')
|
||||
->add('type', EntityType::class, [
|
||||
->add('group', EntityType::class, [
|
||||
'placeholder' => '(Bitte wählen) *',
|
||||
'class' => 'AppBundle\Entity\FewoLodgingGroup',
|
||||
'constraints' => [
|
||||
new NotNull()
|
||||
]
|
||||
])
|
||||
->add('type', EntityType::class, [
|
||||
'placeholder' => '(Bitte wählen) *',
|
||||
'class' => 'AppBundle\Entity\FewoLodgingType',
|
||||
'constraints' => [
|
||||
|
|
|
|||
57
trunk/src/AppBundle/Form/FewoLodgingTypeGroup.php
Normal file
57
trunk/src/AppBundle/Form/FewoLodgingTypeGroup.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Form;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Choice;
|
||||
use Symfony\Component\Validator\Constraints\NotNull;
|
||||
use AppBundle\Entity\FewoSeason;
|
||||
|
||||
|
||||
class FewoLodgingTypeGroup extends AbstractType
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('name', null, [
|
||||
'required' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'AppBundle\Entity\FewoLodgingGroup'
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'appbundle_fewolodgingtypegroup';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
|
|||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Event\PreUpdateEventArgs;
|
||||
use AppBundle\Entity\FewoLodgingImage;
|
||||
use AppBundle\Entity\FewoLodgingGroupImage;
|
||||
use AppBundle\Service\FileManager;
|
||||
|
||||
class DoctrineFileListener
|
||||
|
|
@ -42,7 +43,8 @@ class DoctrineFileListener
|
|||
private function uploadFile($entity)
|
||||
{
|
||||
|
||||
if (!$entity instanceof FewoLodgingImage)
|
||||
|
||||
if (!$entity instanceof FewoLodgingImage && !$entity instanceof FewoLodgingGroupImage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -66,11 +68,16 @@ class DoctrineFileListener
|
|||
|
||||
private function deleteFile($entity)
|
||||
{
|
||||
if(!$entity instanceof FewoLodgingImage)
|
||||
if($entity instanceof FewoLodgingImage)
|
||||
{
|
||||
return;
|
||||
$this->uploader->delete($entity);
|
||||
}
|
||||
|
||||
$this->uploader->delete($entity);
|
||||
if($entity instanceof FewoLodgingGroupImage)
|
||||
{
|
||||
$this->uploader->deleteGroup($entity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -72,6 +72,7 @@ class KernelControllerListener
|
|||
$qb->where($qb->expr()->eq('p.lvl', $i));
|
||||
$qb->andWhere($qb->expr()->eq('p.slug', ':slug'));
|
||||
$qb->setParameter('slug', $slug);
|
||||
|
||||
if ($node != null)
|
||||
{
|
||||
$qb->andWhere($qb->expr()->between('p.lft', $node->getLft(), $node->getRgt()));
|
||||
|
|
@ -100,7 +101,6 @@ class KernelControllerListener
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$node)
|
||||
{
|
||||
// Search for a redirect entry
|
||||
|
|
@ -114,9 +114,9 @@ class KernelControllerListener
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($node)
|
||||
{
|
||||
|
||||
if ($node->getStatus() == 0)
|
||||
{
|
||||
throw new NotFoundHttpException('Inactive page');
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
namespace AppBundle\Service;
|
||||
|
||||
use AppBundle\Entity\FewoLodgingImage;
|
||||
use AppBundle\Entity\FewoLodgingGroupImage;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
|
|
@ -20,6 +21,7 @@ class FileManager
|
|||
public function upload(UploadedFile $file)
|
||||
{
|
||||
$baseFileName = md5(uniqid());
|
||||
|
||||
$fileName = $baseFileName.'.'.$file->guessExtension();
|
||||
|
||||
$file->move($this->getTargetDir(), $fileName);
|
||||
|
|
@ -86,6 +88,13 @@ class FileManager
|
|||
$filesystem->remove($this->getTargetDir().'/'.$image->getFile());
|
||||
}
|
||||
|
||||
public function deleteGroup(FewoLodgingGroupImage $image)
|
||||
{
|
||||
$filesystem = new Filesystem();
|
||||
|
||||
$filesystem->remove($this->getTargetDir().'/'.$image->getFile());
|
||||
}
|
||||
|
||||
public function getTargetDir()
|
||||
{
|
||||
return $this->targetDir;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue