ヤミRoot VoidGate
User / IP
:
216.73.216.143
Host / Server
:
146.88.233.70 / dev.loger.cm
System
:
Linux hybrid1120.fr.ns.planethoster.net 3.10.0-957.21.2.el7.x86_64 #1 SMP Wed Jun 5 14:26:44 UTC 2019 x86_64
Command
|
Upload
|
Create
Mass Deface
|
Jumping
|
Symlink
|
Reverse Shell
Ping
|
Port Scan
|
DNS Lookup
|
Whois
|
Header
|
cURL
:
/
home
/
itrave
/
api
/
src
/
AppBundle
/
Manager
/
Viewing: CabRidePaymentManager.php
<?php namespace AppBundle\Manager; use Doctrine\ORM\EntityManager; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use AppBundle\Entity\Cab; use AppBundle\Entity\CabBooking; use AppBundle\Entity\CabRidePayment; use AppBundle\Entity\PaymentService; class CabRidePaymentManager extends AbstractResourceManager { private $repository = 'AppBundle:CabRidePayment'; private $tokenStorage; private $authChecker; public function __construct(EntityManager $manager,TokenStorage $tokenStorage, AuthorizationChecker $authChecker) { parent::__construct($manager); $this->tokenStorage = $tokenStorage; $this->authChecker = $authChecker; } public function createNewCabRidePayment($cabBooking, $paymentService, $amount, $reference, $user) { // check if the booking is already paid if ( $this->isPaid($cabBooking)) throw new BadRequestHttpException('Booking already paid.'); // check the booking if ( !$cabBooking) throw new BadRequestHttpException('No booking provided'); // check the payment service if ( !$paymentService) throw new BadRequestHttpException('No payment sercice provided'); // check the amount if ( !$amount ) throw new BadRequestHttpException('No amount provided'); if ($amount < $this->getCabBookingTotalCost($cabBooking)) throw new BadRequestHttpException('Provided amount: '. $amount. ' is less than required: '.$this->getCabBookingTotalCost($cabBooking) ); // if no reference is provider, the $operator must refer to a Staff entity with role ROLE_OPERATOR if( !$reference){ if( $paymentService->getType() == PaymentService::TYPE_CASH ){ if( $this->authChecker->isGranted('ROLE_OPERATOR')) $operator = $user; else throw new BadRequestHttpException('Only Operators can achieve Cash payment'); }else throw new BadRequestHttpException('Only cash payments can be achieved without providing a reference: Provide service type is --'.$paymentService->getType(). '-- .' ); }else $operator = null; $cabRidePayment = new CabRidePayment($cabBooking, $paymentService, $amount, $reference, $operator ); return $this->_registerCabRidePayment($cabRidePayment, true); } public function updateCabRidePayment(CabRidePayment $cabRP = null) { // TODO: } public function deleteCabRidePayment() { //TODO } public function getCabRidePayments($companyId, $paymentServiceId, $operatorId) { return $this->manager->getRepository($this->repository) ->search($companyId, $paymentServiceId, $operatorId); } public function getCabBookingTotalCost($cabBooking) { return $cabBooking->getDuration() * $cabBooking->getCab()->getCostPerHour(); } public function isPaid(CabBooking $cabBooking) { if ($this->manager->getRepository($this->repository)->findByCabBooking($cabBooking)) return true; else return false; } private function _registerCabRidePayment($cabRidePayment, $new = false) { if( $new ){ $this->manager->persist($cabRidePayment); } $this->manager->flush(); return $cabRidePayment; } private function _controlUserRights($cabRidePayment) { if($this->$authChecker->isGranted('ROLE_SUPER_ADMIN')) return true; else{ return false; } } }
Coded With 💗 by
0x6ick