Skip to content

Commit

Permalink
refactor reservationpermission into ban
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvanspauwen committed Nov 6, 2023
1 parent e2a03d0 commit d950df4
Show file tree
Hide file tree
Showing 19 changed files with 175 additions and 412 deletions.
135 changes: 134 additions & 1 deletion module/ShopBundle/Controller/Admin/BanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
namespace ShopBundle\Controller\Admin;

use Laminas\View\Model\ViewModel;
use ShopBundle\Repository\Reservation\Ban;

/**
* BanPermissionController
*
* @author Floris Kint <[email protected]>
*/
class BanController extends \CommonBundle\Component\Controller\ActionController\AdminController
{
public function manageAction()
Expand Down Expand Up @@ -39,4 +45,131 @@ public function oldAction()
)
);
}
}

// shop_reservationPermission_add

public function addAction()
{
$form = $this->getForm('shop_reservation_ban_add');

if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
$form->setData($formData);

if ($form->isValid()) {
error_log("before hydrate");
$ban = $form->hydrateObject();
error_log("before persist");
$this->getEntityManager()->persist($ban);
error_log("before flush");
$this->getEntityManager()->flush();

$this->flashMessenger()->success(
'Success',
'The ban was successfully created!'
);

$this->redirect()->toRoute(
'shop_admin_shop_ban',
array(
'action' => 'add',
)
);

return new ViewModel();
}
}

return new ViewModel(
array(
'form' => $form,
)
);
}

public function deleteAction()
{
$this->initAjax();

$ban = $this->getBanEntity();
if ($ban === null) {
return new ViewModel();
}

$this->getEntityManager()->remove($ban);
$this->getEntityManager()->flush();

return new ViewModel(
array(
'result' => array(
'status' => 'success',
),
)
);
}

/**
* @return Ban|null
*/
private function getBanEntity()
{
$ban = $this->getEntityById('ShopBundle\Entity\Reservation\Ban');

if (!($ban instanceof Ban)) {
$this->flashMessenger()->error(
'Error',
'No ban was found!'
);

$this->redirect()->toRoute(
'shop_admin_shop_ban',
array(
'action' => 'manage',
)
);
return;
}
return $ban;
}

public function searchAction()
{
// $this->initAjax();
//
// $numResults = $this->getEntityManager()
// ->getRepository('CommonBundle\Entity\General\Config')
// ->getConfigValue('search_max_results');
//
// $reservationPermissions = $this->search()
// ->setMaxResults($numResults)
// ->getResult();
//
// $result = array();
// foreach ($reservationPermissions as $reservationPermission) {
// $item = (object) array();
// $item->id = $reservationPermission->getPerson()->getId();
// $item->name = $reservationPermission->getPerson()->getFullName();
// $item->reservationsAllowed = $reservationPermission->getReservationsAllowed();
// $result[] = $item;
// }
//
// return new ViewModel(
// array(
// 'result' => $result,
// )
// );
}

/**
* @return \Doctrine\ORM\Query|null
*/
private function search()
{
// switch ($this->getParam('field')) {
// case 'name':
// return $this->getEntityManager()
// ->getRepository('ShopBundle\Entity\Reservation\Permission')
// ->findByNameQuery($this->getParam('string'));
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use ShopBundle\Component\NoShow\NoShowConfig;
use ShopBundle\Entity\Reservation;
use ShopBundle\Entity\Reservation\Ban;
use ShopBundle\Entity\Reservation\Permission as ReservationPermission;
use ShopBundle\Entity\Session as SalesSession;

/**
Expand Down
175 changes: 0 additions & 175 deletions module/ShopBundle/Controller/Admin/ReservationPermissionController.php

This file was deleted.

67 changes: 0 additions & 67 deletions module/ShopBundle/Entity/Reservation/Permission.php

This file was deleted.

Loading

0 comments on commit d950df4

Please sign in to comment.