Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\DataFixtures\ORM;
- use AppBundle\Entity\Ride;
- use AppBundle\Service\BookingChargeChargerService;
- use Doctrine\Common\DataFixtures\AbstractFixture;
- use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
- use Doctrine\Common\Persistence\ObjectManager;
- use Symfony\Component\DependencyInjection\ContainerAwareInterface;
- use Symfony\Component\DependencyInjection\ContainerInterface;
- use Symfony\Component\Form\Form;
- use UserBundle\Entity\User;
- class Fixtures40Bookings extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
- {
- /**
- * @var ContainerInterface
- */
- private $container;
- /**
- * {@inheritDoc}
- */
- public function setContainer(ContainerInterface $container = null)
- {
- $this->container = $container;
- }
- /**
- * Load data fixtures with the passed EntityManager
- *
- * @param \Doctrine\Common\Persistence\ObjectManager $manager
- */
- function load(ObjectManager $manager)
- {
- $bookingFakeCreator = $this->container->get('booking.fake.creator');
- /**************************************************************************************************************
- * BOOKINGS FOR RIDE MR-0000
- *************************************************************************************************************/
- /** @var Ride $ride */
- $ride = $this->getReference("ride-MR-0000");
- $bookingFakeCreator->createFakeBooking(
- array($ride->getMainRideSegmentBelongingToOutward()),
- 1,
- [
- 'user' => $this->getReference("admin"),
- ]
- );
- $bookingFakeCreator->createFakeBooking(
- array($ride->getMainRideSegmentBelongingToOutward(), $ride->getMainRideSegmentBelongingToReturn()),
- 2,
- [
- 'user' => $this->getReference("admin"),
- ]
- );
- /**************************************************************************************************************
- * BOOKINGS FOR RIDE CH-0001
- *************************************************************************************************************/
- /** @var Ride $ride */
- $ride = $this->getReference("ride-CH-0001");
- // confirm
- $this->container->get('ride.confirmer')->confirmRide($ride);
- $bookingFakeCreator->createFakeBooking(
- array($ride->getMainRideSegmentBelongingToOutward(), $ride->getMainRideSegmentBelongingToReturn()),
- 2,
- [
- 'user' => $this->getReference("admin"),
- 'booking_optionals' => [
- $this->getReference('booking_optional_SKIPASS'),
- $this->getReference('booking_optional_SKI_LESSON'),
- $this->getReference('booking_optional_AXA'),
- ],
- ]
- );
- /*
- * process BookingCharges
- *
- * @todo this code is duplicated of AdminBundle\Command\ContinuousCommand: refactor ContinuousCommand code in a service and call the service from here
- */
- /** @var BookingChargeChargerService */
- $bookingChargeCharger = $this->container->get('booking_charge.charger');
- $bookingChargesIds = $manager->getRepository('AppBundle:BookingCharge')->findChargeable(true);
- foreach ($bookingChargesIds as $bookingChargeId) {
- $bookingCharge = $manager->getRepository('AppBundle:BookingCharge')->find($bookingChargeId);
- $bookingChargeCharger->chargeBookingChargeOrThrowBookingException($bookingCharge);
- }
- /** end process BookingCharges */
- /**************************************************************************************************************
- * flush
- *************************************************************************************************************/
- $manager->flush();
- }
- /**
- * {@inheritDoc}
- */
- public function getOrder()
- {
- return 40; // the order in which fixtures will be loaded
- }
- }
Add Comment
Please, Sign In to add comment