File manager - Edit - /home/premiey/www/wp-includes/images/media/Factory.tar
Back
User/ProviderFactory.php 0000666 00000006160 15165637651 0011343 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\User; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; /** * Class ProviderFactory * * @package AmeliaBooking\Domain\Factory\User */ class ProviderFactory extends UserFactory { /** * @param array $providers * @param array $services * @param array $providersServices * * @return Collection * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function createCollection($providers, $services = [], $providersServices = []) { $providersCollection = new Collection(); foreach ($providers as $providerKey => $providerArray) { $providersCollection->addItem( self::create($providerArray), $providerKey ); if ($providersServices && array_key_exists($providerKey, $providersServices)) { foreach ((array)$providersServices[$providerKey] as $serviceKey => $providerService) { if (array_key_exists($serviceKey, $services)) { $providersCollection->getItem($providerKey)->getServiceList()->addItem( ServiceFactory::create( array_merge( $services[$serviceKey], $providerService ) ), $serviceKey ); } } } } return $providersCollection; } /** * @param array $rows * * @return array */ public static function reformat($rows) { $data = []; foreach ($rows as $row) { $id = $row['provider_id']; $googleCalendarId = $row['google_calendar_id']; if ($id && empty($data[$id])) { $data[$id] = [ 'id' => $id, 'type' => $row['provider_type'], 'firstName' => $row['provider_firstName'], 'lastName' => $row['provider_lastName'], 'email' => $row['provider_email'], 'note' => $row['provider_note'], 'description' => $row['provider_description'], 'phone' => $row['provider_phone'], 'gender' => $row['provider_gender'], 'translations' => $row['provider_translations'], ]; } if ($data[$id] && $googleCalendarId && empty($data[$id]['googleCalendar'])) { $data[$id]['googleCalendar'] = [ 'id' => $row['google_calendar_id'], 'token' => $row['google_calendar_token'], 'calendarId' => isset($row['google_calendar_calendar_id']) ? $row['google_calendar_calendar_id'] : null ]; } } return $data; } } User/UserFactory.php 0000666 00000025136 15165637651 0010473 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\User; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\User\Customer; use AmeliaBooking\Domain\Entity\User\Manager; use AmeliaBooking\Domain\Entity\User\Admin; use AmeliaBooking\Domain\Entity\User\Provider; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; use AmeliaBooking\Domain\Factory\Google\GoogleCalendarFactory; use AmeliaBooking\Domain\Factory\Outlook\OutlookCalendarFactory; use AmeliaBooking\Domain\Factory\Schedule\PeriodLocationFactory; use AmeliaBooking\Domain\Factory\Schedule\PeriodServiceFactory; use AmeliaBooking\Domain\Factory\Schedule\SpecialDayFactory; use AmeliaBooking\Domain\Factory\Schedule\SpecialDayPeriodFactory; use AmeliaBooking\Domain\Factory\Schedule\SpecialDayPeriodLocationFactory; use AmeliaBooking\Domain\Factory\Schedule\SpecialDayPeriodServiceFactory; use AmeliaBooking\Domain\ValueObjects\DateTime\Birthday; use AmeliaBooking\Domain\ValueObjects\Gender; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\String\Password; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Email; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Phone; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Factory\Schedule\DayOffFactory; use AmeliaBooking\Domain\Factory\Schedule\TimeOutFactory; use AmeliaBooking\Domain\Factory\Schedule\PeriodFactory; use AmeliaBooking\Domain\Factory\Schedule\WeekDayFactory; /** * Class UserFactory * * @package AmeliaBooking\Domain\Factory\User */ class UserFactory { /** * @param $data * * @return Admin|Customer|Manager|Provider * @throws InvalidArgumentException */ public static function create($data) { if (!isset($data['type']) || !$data['email']) { $data['type'] = 'customer'; } switch ($data['type']) { case 'admin': $user = new Admin( new Name(trim($data['firstName'])), new Name(trim($data['lastName'])), new Email($data['email']) ); break; case 'provider': $weekDayList = []; $dayOffList = []; $specialDayList = []; $serviceList = []; $appointmentList = []; if (isset($data['weekDayList'])) { foreach ((array)$data['weekDayList'] as $weekDay) { $timeOutList = []; if (isset($weekDay['timeOutList'])) { foreach ((array)$weekDay['timeOutList'] as $timeOut) { $timeOutList[] = TimeOutFactory::create($timeOut); } $weekDay['timeOutList'] = $timeOutList; } $periodList = []; if (isset($weekDay['periodList'])) { foreach ((array)$weekDay['periodList'] as $period) { $periodServiceList = []; if (isset($period['periodServiceList'])) { foreach ((array)$period['periodServiceList'] as $periodService) { $periodServiceList[] = PeriodServiceFactory::create($periodService); } } $periodLocationList = []; if (isset($period['periodLocationList'])) { foreach ((array)$period['periodLocationList'] as $periodLocation) { $periodLocationList[] = PeriodLocationFactory::create($periodLocation); } } $period['periodServiceList'] = $periodServiceList; $period['periodLocationList'] = $periodLocationList; $periodList[] = PeriodFactory::create($period); } $weekDay['periodList'] = $periodList; } $weekDayList[] = WeekDayFactory::create($weekDay); } } if (isset($data['specialDayList'])) { foreach ((array)$data['specialDayList'] as $specialDay) { $periodList = []; if (isset($specialDay['periodList'])) { foreach ((array)$specialDay['periodList'] as $period) { $periodServiceList = []; if (isset($period['periodServiceList'])) { foreach ((array)$period['periodServiceList'] as $periodService) { $periodServiceList[] = SpecialDayPeriodServiceFactory::create($periodService); } } $periodLocationList = []; if (isset($period['periodLocationList'])) { foreach ((array)$period['periodLocationList'] as $periodLocation) { $periodLocationList[] = SpecialDayPeriodLocationFactory::create($periodLocation); } } $period['periodServiceList'] = $periodServiceList; $period['periodLocationList'] = $periodLocationList; $periodList[] = SpecialDayPeriodFactory::create($period); } $specialDay['periodList'] = $periodList; } $specialDayList[] = SpecialDayFactory::create($specialDay); } } if (isset($data['dayOffList'])) { foreach ((array)$data['dayOffList'] as $dayOff) { $dayOffList[] = DayOffFactory::create($dayOff); } } if (isset($data['serviceList'])) { foreach ((array)$data['serviceList'] as $service) { $serviceList[$service['id']] = ServiceFactory::create($service); } } $user = new Provider( new Name(trim($data['firstName'])), new Name(trim($data['lastName'])), new Email($data['email']), new Phone(isset($data['phone']) ? $data['phone'] : null), new Collection($weekDayList), new Collection($serviceList), new Collection($dayOffList), new Collection($specialDayList), new Collection($appointmentList) ); if (!empty($data['password'])) { $user->setPassword(new Password($data['password'])); } if (!empty($data['locationId'])) { $user->setLocationId(new Id($data['locationId'])); } if (!empty($data['googleCalendar']) && isset($data['googleCalendar']['token'])) { $user->setGoogleCalendar(GoogleCalendarFactory::create($data['googleCalendar'])); } if (!empty($data['outlookCalendar']) && isset($data['outlookCalendar']['token'])) { $user->setOutlookCalendar(OutlookCalendarFactory::create($data['outlookCalendar'])); } if (!empty($data['zoomUserId'])) { $user->setZoomUserId(new Name($data['zoomUserId'])); } if (!empty($data['timeZone'])) { $user->setTimeZone(new Name($data['timeZone'])); } if (!empty($data['id'])) { $user->setId(new Id($data['id'])); } if (!empty($data['translations'])) { $user->setTranslations(new Json($data['translations'])); } if (!empty($data['description'])) { $user->setDescription(new Description($data['description'])); } break; case 'manager': $user = new Manager( new Name(trim($data['firstName'])), new Name(trim($data['lastName'])), new Email($data['email']) ); break; case 'customer': default: $user = new Customer( new Name(trim($data['firstName'])), new Name(trim($data['lastName'])), new Email($data['email'] ?: null), new Phone(!empty($data['phone']) ? $data['phone'] : null), new Gender(!empty($data['gender']) ? strtolower($data['gender']) : null) ); if (!empty($data['translations'])) { $user->setTranslations(new Json($data['translations'])); } break; } if (!empty($data['countryPhoneIso'])) { $user->setCountryPhoneIso(new Name($data['countryPhoneIso'])); } if (!empty($data['birthday'])) { if (is_string($data['birthday'])) { $user->setBirthday(new Birthday(\DateTime::createFromFormat('Y-m-d', $data['birthday']))); } else { $user->setBirthday(new Birthday($data['birthday'])); } } if (!empty($data['id'])) { $user->setId(new Id($data['id'])); } if (!empty($data['externalId'])) { $user->setExternalId(new Id($data['externalId'])); } if (!empty($data['pictureFullPath']) && !empty($data['pictureThumbPath'])) { $user->setPicture(new Picture($data['pictureFullPath'], $data['pictureThumbPath'])); } if (!empty($data['status'])) { $user->setStatus(new Status($data['status'])); } if (!empty($data['note'])) { $user->setNote(new Description($data['note'])); } return $user; } } Schedule/SpecialDayPeriodFactory.php 0000666 00000002317 15165637651 0013550 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Schedule\SpecialDayPeriod; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class SpecialDayPeriodFactory * * @package AmeliaBooking\Domain\Factory\Schedule */ class SpecialDayPeriodFactory { /** * @param array $data * * @return SpecialDayPeriod * @throws InvalidArgumentException */ public static function create($data) { $period = new SpecialDayPeriod( new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['startTime'])), new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['endTime'])), new Collection($data['periodServiceList']), new Collection($data['periodLocationList']) ); if (isset($data['id'])) { $period->setId(new Id($data['id'])); } if (isset($data['locationId'])) { $period->setLocationId(new Id($data['locationId'])); } return $period; } } Schedule/TimeOutFactory.php 0000666 00000001471 15165637651 0011755 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\TimeOut; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; class TimeOutFactory { /** * @param array $data * * @return TimeOut * @throws InvalidArgumentException */ public static function create($data) { $timeOut = new TimeOut( new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['startTime'])), new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['endTime'])) ); if (isset($data['id'])) { $timeOut->setId(new Id($data['id'])); } return $timeOut; } } Schedule/SpecialDayFactory.php 0000666 00000002155 15165637651 0012405 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\SpecialDay; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\Collection\Collection; /** * Class SpecialDayFactory * * @package AmeliaBooking\Domain\Factory\Schedule */ class SpecialDayFactory { /** * @param array $data * * @return SpecialDay * @throws InvalidArgumentException */ public static function create($data) { $specialDay = new SpecialDay( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['startDate'])), new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['endDate'])), new Collection(isset($data['periodList']) ? $data['periodList'] : []) ); if (isset($data['id'])) { $specialDay->setId(new Id($data['id'])); } return $specialDay; } } Schedule/PeriodServiceFactory.php 0000666 00000001060 15165637651 0013124 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\PeriodService; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; class PeriodServiceFactory { /** * @param array $data * * @return PeriodService */ public static function create($data) { $periodService = new PeriodService( new Id($data['serviceId']) ); if (isset($data['id'])) { $periodService->setId(new Id($data['id'])); } return $periodService; } } Schedule/DayOffFactory.php 0000666 00000002220 15165637651 0011530 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\DayOff; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\DateRepeat; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class DayOffFactory * * @package AmeliaBooking\Domain\Factory\Schedule */ class DayOffFactory { /** * @param array $data * * @return DayOff * @throws InvalidArgumentException */ public static function create($data) { $dayOff = new DayOff( new Name($data['name']), new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['startDate'])), new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['endDate'])), new DateRepeat($data['repeat']) ); if (isset($data['id'])) { $dayOff->setId(new Id($data['id'])); } return $dayOff; } } Schedule/WeekDayFactory.php 0000666 00000002332 15165637651 0011715 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\WeekDay; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\Collection\Collection; /** * Class WeekDayFactory * * @package AmeliaBooking\Domain\Factory\Schedule */ class WeekDayFactory { /** * @param array $data * * @return WeekDay * @throws InvalidArgumentException */ public static function create($data) { $weekDay = new WeekDay( new IntegerValue($data['dayIndex']), new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['startTime'])), new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['endTime'])), new Collection(isset($data['timeOutList']) ? $data['timeOutList'] : []), new Collection(isset($data['periodList']) ? $data['periodList'] : []) ); if (isset($data['id'])) { $weekDay->setId(new Id($data['id'])); } return $weekDay; } } Schedule/SpecialDayPeriodLocationFactory.php 0000666 00000001102 15165637651 0015230 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\PeriodLocation; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; class SpecialDayPeriodLocationFactory { /** * @param array $data * * @return PeriodLocation */ public static function create($data) { $periodLocation = new PeriodLocation( new Id($data['locationId']) ); if (isset($data['id'])) { $periodLocation->setId(new Id($data['id'])); } return $periodLocation; } } Schedule/SpecialDayPeriodServiceFactory.php 0000666 00000001072 15165637651 0015066 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\PeriodService; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; class SpecialDayPeriodServiceFactory { /** * @param array $data * * @return PeriodService */ public static function create($data) { $periodService = new PeriodService( new Id($data['serviceId']) ); if (isset($data['id'])) { $periodService->setId(new Id($data['id'])); } return $periodService; } } Schedule/PeriodLocationFactory.php 0000666 00000001070 15165637651 0013275 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Entity\Schedule\PeriodLocation; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; class PeriodLocationFactory { /** * @param array $data * * @return PeriodLocation */ public static function create($data) { $periodLocation = new PeriodLocation( new Id($data['locationId']) ); if (isset($data['id'])) { $periodLocation->setId(new Id($data['id'])); } return $periodLocation; } } Schedule/PeriodFactory.php 0000666 00000002235 15165637651 0011610 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Schedule; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Schedule\Period; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class PeriodFactory * * @package AmeliaBooking\Domain\Factory\Schedule */ class PeriodFactory { /** * @param array $data * * @return Period * @throws InvalidArgumentException */ public static function create($data) { $period = new Period( new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['startTime'])), new DateTimeValue(\DateTime::createFromFormat('H:i:s', $data['endTime'])), new Collection($data['periodServiceList']), new Collection($data['periodLocationList']) ); if (isset($data['id'])) { $period->setId(new Id($data['id'])); } if (isset($data['locationId'])) { $period->setLocationId(new Id($data['locationId'])); } return $period; } } Google/GoogleCalendarFactory.php 0000666 00000001652 15165637651 0012716 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Google; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Google\GoogleCalendar; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class GoogleCalendarFactory * * @package AmeliaBooking\Domain\Factory\Google */ class GoogleCalendarFactory { /** * @param $data * * @return GoogleCalendar * @throws InvalidArgumentException */ public static function create($data) { $googleCalendar = new GoogleCalendar( new Token($data['token']), new Name(empty($data['calendarId']) ? null : $data['calendarId']) ); if (isset($data['id'])) { $googleCalendar->setId(new Id($data['id'])); } return $googleCalendar; } } Booking/SlotsEntitiesFactory.php 0000666 00000000727 15165637651 0013037 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking; use AmeliaBooking\Domain\Entity\Booking\SlotsEntities; /** * Class SlotsEntitiesFactory * * @package AmeliaBooking\Domain\Factory\Booking */ class SlotsEntitiesFactory { /** * @return SlotsEntities */ public static function create() { return new SlotsEntities(); } } Booking/Appointment/CustomerBookingFactory.php 0000666 00000023104 15165637651 0015630 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Appointment; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageCustomerService; use AmeliaBooking\Domain\Entity\Booking\Appointment\CustomerBooking; use AmeliaBooking\Domain\Factory\Bookable\Service\PackageCustomerServiceFactory; use AmeliaBooking\Domain\Factory\Booking\Event\CustomerBookingEventTicketFactory; use AmeliaBooking\Domain\Factory\Coupon\CouponFactory; use AmeliaBooking\Domain\Factory\Payment\PaymentFactory; use AmeliaBooking\Domain\Factory\User\UserFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\PositiveDuration; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class CustomerBookingFactory * * @package AmeliaBooking\Domain\Factory\Booking\Appointment */ class CustomerBookingFactory { /** * @param $data * * @return CustomerBooking * @throws InvalidArgumentException */ public static function create($data) { $customerBooking = new CustomerBooking( new Id($data['customerId']), new BookingStatus($data['status']), new IntegerValue($data['persons']) ); if (isset($data['id'])) { $customerBooking->setId(new Id($data['id'])); } if (isset($data['price'])) { $customerBooking->setPrice(new Price($data['price'])); } if (isset($data['appointmentId'])) { $customerBooking->setAppointmentId(new Id($data['appointmentId'])); } if (isset($data['couponId'])) { $customerBooking->setCouponId(new Id($data['couponId'])); } if (isset($data['coupon'])) { $customerBooking->setCoupon(CouponFactory::create($data['coupon'])); } if (isset($data['customer'])) { $customerBooking->setCustomer(UserFactory::create($data['customer'])); } if (isset($data['customFields'])) { $customerBooking->setCustomFields(new Json($data['customFields'])); } if (isset($data['info'])) { $customerBooking->setInfo(new Json($data['info'])); } if (isset($data['utcOffset'])) { $customerBooking->setUtcOffset(new IntegerValue($data['utcOffset'])); } if (isset($data['aggregatedPrice'])) { $customerBooking->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice'])); } if (isset($data['isChangedStatus'])) { $customerBooking->setChangedStatus(new BooleanValueObject($data['isChangedStatus'])); } if (isset($data['isLastBooking'])) { $customerBooking->setLastBooking(new BooleanValueObject($data['isLastBooking'])); } if (isset($data['deposit'])) { $customerBooking->setDeposit(new BooleanValueObject($data['deposit'])); } if (isset($data['packageCustomerService'])) { /** @var PackageCustomerService $packageCustomerService */ $packageCustomerService = PackageCustomerServiceFactory::create($data['packageCustomerService']); $customerBooking->setPackageCustomerService($packageCustomerService); } if (isset($data['duration'])) { $customerBooking->setDuration(new PositiveDuration($data['duration'])); } $payments = new Collection(); if (isset($data['payments'])) { foreach ((array)$data['payments'] as $key => $value) { $payments->addItem( PaymentFactory::create($value), $key ); } } $customerBooking->setPayments($payments); $extras = new Collection(); if (isset($data['extras'])) { foreach ((array)$data['extras'] as $key => $value) { $extras->addItem( CustomerBookingExtraFactory::create($value), $key ); } } $customerBooking->setExtras($extras); if (isset($data['token'])) { $customerBooking->setToken(new Token($data['token'])); } $ticketsBooking = new Collection(); if (!empty($data['ticketsData'])) { foreach ((array)$data['ticketsData'] as $key => $value) { $ticketsBooking->addItem( CustomerBookingEventTicketFactory::create($value), $key ); } } $customerBooking->setTicketsBooking($ticketsBooking); if (!empty($data['created'])) { $customerBooking->setCreated(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['created']))); } return $customerBooking; } /** * @param array $rows * * @return array */ public static function reformat($rows) { $data = []; foreach ($rows as $row) { $id = $row['booking_id']; $customerId = !empty($row['customer_id']) ? $row['customer_id'] : null; $paymentId = !empty($row['payment_id']) ? $row['payment_id'] : null; $couponId = !empty($row['coupon_id']) ? $row['coupon_id'] : null; $bookingEventTicketId = !empty($row['booking_ticket_id']) ? $row['booking_ticket_id'] : null; if ($id && empty($data[$id])) { $data[$id] = [ 'id' => $id, 'appointmentId' => $row['booking_appointmentId'], 'customerId' => $row['booking_customerId'], 'status' => $row['booking_status'], 'price' => $row['booking_price'], 'persons' => $row['booking_persons'], 'couponId' => $row['booking_couponId'], 'customFields' => !empty($row['booking_customFields']) ? $row['booking_customFields'] : null, 'info' => !empty($row['booking_info']) ? $row['booking_info'] : null, 'utcOffset' => $row['booking_utcOffset'], 'aggregatedPrice' => $row['booking_aggregatedPrice'], 'duration' => !empty($row['booking_duration']) ? $row['booking_duration'] : null, ]; } if ($data[$id] && $customerId && empty($data[$id]['customer'])) { $data[$id]['customer'] = [ 'id' => $customerId, 'firstName' => $row['customer_firstName'], 'lastName' => $row['customer_lastName'], 'email' => $row['customer_email'], 'note' => $row['customer_note'], 'phone' => $row['customer_phone'], 'gender' => $row['customer_gender'], 'birthday' => $row['customer_birthday'], ]; } if ($data[$id] && $paymentId && empty($data[$id]['payments'][$paymentId])) { $data[$id]['payments'][$paymentId] = [ 'id' => $paymentId, 'customerBookingId' => $id, 'amount' => $row['payment_amount'], 'dateTime' => $row['payment_dateTime'], 'status' => $row['payment_status'], 'gateway' => $row['payment_gateway'], 'gatewayTitle' => $row['payment_gatewayTitle'], 'transactionId' => $row['payment_transactionId'], 'parentId' => $row['payment_parentId'], 'data' => $row['payment_data'], 'wcOrderId' => !empty($row['payment_wcOrderId']) ? $row['payment_wcOrderId'] : null, ]; } if ($data[$id] && $couponId && empty($data[$id]['coupon'])) { $data[$id]['coupon'] = [ 'id' => $couponId, 'code' => $row['coupon_code'], 'discount' => $row['coupon_discount'], 'deduction' => $row['coupon_deduction'], 'limit' => $row['coupon_limit'], 'customerLimit' => $row['coupon_customerLimit'], 'status' => $row['coupon_status'], ]; } if ($data[$id] && $bookingEventTicketId && empty($data[$id]['ticketsData'][$bookingEventTicketId])) { $data[$id]['ticketsData'][$bookingEventTicketId] = [ 'id' => $bookingEventTicketId, 'eventTicketId' => $row['booking_ticket_eventTicketId'], 'customerBookingId' => $id, 'persons' => $row['booking_ticket_persons'], 'price' => $row['booking_ticket_price'], ]; } } return $data; } } Booking/Appointment/CustomerBookingExtraFactory.php 0000666 00000003074 15165637651 0016640 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Appointment; use AmeliaBooking\Domain\Entity\Booking\Appointment\CustomerBookingExtra; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; /** * Class CustomerBookingExtraFactory * * @package AmeliaBooking\Domain\Factory\Booking\Appointment */ class CustomerBookingExtraFactory { /** * @param $data * * @return CustomerBookingExtra * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function create($data) { $customerBookingExtra = new CustomerBookingExtra( new Id($data['extraId']), new PositiveInteger($data['quantity']) ); if (isset($data['id'])) { $customerBookingExtra->setId(new Id($data['id'])); } if (isset($data['customerBookingId'])) { $customerBookingExtra->setCustomerBookingId(new Id($data['customerBookingId'])); } if (isset($data['price'])) { $customerBookingExtra->setPrice(new Price($data['price'])); } if (isset($data['aggregatedPrice'])) { $customerBookingExtra->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice'])); } return $customerBookingExtra; } } Booking/Appointment/AppointmentFactory.php 0000666 00000037704 15165637651 0015027 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Appointment; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Appointment\Appointment; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; use AmeliaBooking\Domain\Factory\User\UserFactory; use AmeliaBooking\Domain\Factory\Zoom\ZoomFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class AppointmentFactory * * @package AmeliaBooking\Domain\Factory\Booking\Appointment */ class AppointmentFactory { /** * @param $data * * @return Appointment * @throws InvalidArgumentException */ public static function create($data) { $appointment = new Appointment( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['bookingStart'])), new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['bookingEnd'])), $data['notifyParticipants'], new Id($data['serviceId']), new Id($data['providerId']) ); if (!empty($data['id'])) { $appointment->setId(new Id($data['id'])); } if (!empty($data['parentId'])) { $appointment->setParentId(new Id($data['parentId'])); } if (!empty($data['locationId'])) { $appointment->setLocationId(new Id($data['locationId'])); } if (isset($data['internalNotes'])) { $appointment->setInternalNotes(new Description($data['internalNotes'])); } if (isset($data['status'])) { $appointment->setStatus(new BookingStatus($data['status'])); } if (isset($data['provider'])) { $appointment->setProvider(UserFactory::create($data['provider'])); } if (isset($data['service'])) { $appointment->setService(ServiceFactory::create($data['service'])); } if (!empty($data['googleCalendarEventId'])) { $appointment->setGoogleCalendarEventId(new Token($data['googleCalendarEventId'])); } if (!empty($data['googleMeetUrl'])) { $appointment->setGoogleMeetUrl($data['googleMeetUrl']); } if (!empty($data['outlookCalendarEventId'])) { $appointment->setOutlookCalendarEventId(new Label($data['outlookCalendarEventId'])); } if (!empty($data['zoomMeeting']['id'])) { $zoomMeeting = ZoomFactory::create( $data['zoomMeeting'] ); $appointment->setZoomMeeting($zoomMeeting); } if (isset($data['lessonSpace']) && !empty($data['lessonSpace'])) { $appointment->setLessonSpace($data['lessonSpace']); } if (isset($data['isRescheduled'])) { $appointment->setRescheduled(new BooleanValueObject($data['isRescheduled'])); } $bookings = new Collection(); if (isset($data['bookings'])) { foreach ((array)$data['bookings'] as $key => $value) { $bookings->addItem( CustomerBookingFactory::create($value), $key ); } } $appointment->setBookings($bookings); return $appointment; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $appointments = []; foreach ($rows as $row) { $appointmentId = $row['appointment_id']; $bookingId = isset($row['booking_id']) ? $row['booking_id'] : null; $bookingExtraId = isset($row['bookingExtra_id']) ? $row['bookingExtra_id'] : null; $paymentId = isset($row['payment_id']) ? $row['payment_id'] : null; $couponId = isset($row['coupon_id']) ? $row['coupon_id'] : null; $customerId = isset($row['customer_id']) ? $row['customer_id'] : null; $providerId = isset($row['provider_id']) ? $row['provider_id'] : null; $serviceId = isset($row['service_id']) ? $row['service_id'] : null; if (!array_key_exists($appointmentId, $appointments)) { $zoomMeetingJson = !empty($row['appointment_zoom_meeting']) ? json_decode($row['appointment_zoom_meeting'], true) : null; $appointments[$appointmentId] = [ 'id' => $appointmentId, 'parentId' => isset($row['appointment_parentId']) ? $row['appointment_parentId'] : null, 'bookingStart' => DateTimeService::getCustomDateTimeFromUtc( $row['appointment_bookingStart'] ), 'bookingEnd' => DateTimeService::getCustomDateTimeFromUtc( $row['appointment_bookingEnd'] ), 'notifyParticipants' => isset($row['appointment_notifyParticipants']) ? $row['appointment_notifyParticipants'] : null, 'serviceId' => $row['appointment_serviceId'], 'providerId' => $row['appointment_providerId'], 'locationId' => isset($row['appointment_locationId']) ? $row['appointment_locationId'] : null, 'internalNotes' => isset($row['appointment_internalNotes']) ? $row['appointment_internalNotes'] : null, 'status' => $row['appointment_status'], 'googleCalendarEventId' => isset($row['appointment_google_calendar_event_id']) ? $row['appointment_google_calendar_event_id'] : null, 'googleMeetUrl' => isset($row['appointment_google_meet_url']) ? $row['appointment_google_meet_url'] : null, 'outlookCalendarEventId' => isset($row['appointment_outlook_calendar_event_id']) ? $row['appointment_outlook_calendar_event_id'] : null, 'zoomMeeting' => [ 'id' => $zoomMeetingJson ? $zoomMeetingJson['id'] : null, 'startUrl' => $zoomMeetingJson ? $zoomMeetingJson['startUrl'] : null, 'joinUrl' => $zoomMeetingJson ? $zoomMeetingJson['joinUrl'] : null, ], 'lessonSpace' => $row['appointment_lesson_space'], ]; } if ($bookingId && !isset($appointments[$appointmentId]['bookings'][$bookingId])) { $appointments[$appointmentId]['bookings'][$bookingId] = [ 'id' => $bookingId, 'appointmentId' => $appointmentId, 'customerId' => $row['booking_customerId'], 'status' => $row['booking_status'], 'couponId' => $couponId, 'price' => $row['booking_price'], 'persons' => $row['booking_persons'], 'customFields' => isset($row['booking_customFields']) ? $row['booking_customFields'] : null, 'info' => isset($row['booking_info']) ? $row['booking_info'] : null, 'utcOffset' => isset($row['booking_utcOffset']) ? $row['booking_utcOffset'] : null, 'aggregatedPrice' => isset($row['booking_aggregatedPrice']) ? $row['booking_aggregatedPrice'] : null, 'packageCustomerService' => !empty($row['booking_packageCustomerServiceId']) ? [ 'id' => $row['booking_packageCustomerServiceId'], 'serviceId' => !empty($row['package_customer_service_serviceId']) ? $row['package_customer_service_serviceId'] : null, 'bookingsCount' => !empty($row['package_customer_service_bookingsCount']) ? $row['package_customer_service_bookingsCount'] : null, 'packageCustomer' => [ 'id' => !empty($row['package_customer_id']) ? $row['package_customer_id'] : null, 'packageId' => !empty($row['package_customer_packageId']) ? $row['package_customer_packageId'] : null, 'price' => !empty($row['package_customer_price']) ? $row['package_customer_price'] : null, 'couponId' => !empty($row['package_customer_couponId']) ? $row['package_customer_couponId'] : null, ] ] : null, 'duration' => isset($row['booking_duration']) ? $row['booking_duration'] : null, 'created' => !empty($row['booking_created']) ? DateTimeService::getCustomDateTimeFromUtc($row['booking_created']) : null, ]; } if ($bookingId && $bookingExtraId) { $appointments[$appointmentId]['bookings'][$bookingId]['extras'][$bookingExtraId] = [ 'id' => $bookingExtraId, 'customerBookingId' => $bookingId, 'extraId' => $row['bookingExtra_extraId'], 'quantity' => $row['bookingExtra_quantity'], 'price' => $row['bookingExtra_price'], 'aggregatedPrice' => $row['bookingExtra_aggregatedPrice'] ]; } if ($bookingId && $paymentId) { $appointments[$appointmentId]['bookings'][$bookingId]['payments'][$paymentId] = [ 'id' => $paymentId, 'customerBookingId' => $bookingId, 'packageCustomerId' => !empty($row['payment_packageCustomerId']) ? $row['payment_packageCustomerId'] : null, 'status' => $row['payment_status'], 'dateTime' => DateTimeService::getCustomDateTimeFromUtc($row['payment_dateTime']), 'gateway' => $row['payment_gateway'], 'gatewayTitle' => $row['payment_gatewayTitle'], 'transactionId' => $row['payment_transactionId'], 'parentId' => $row['payment_parentId'], 'amount' => $row['payment_amount'], 'data' => $row['payment_data'], 'wcOrderId' => !empty($row['payment_wcOrderId']) ? $row['payment_wcOrderId'] : null, 'created' => !empty($row['payment_created']) ? $row['payment_created'] : null, ]; } if ($bookingId && $couponId) { $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['id'] = $couponId; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['code'] = $row['coupon_code']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['discount'] = $row['coupon_discount']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['deduction'] = $row['coupon_deduction']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['limit'] = $row['coupon_limit']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['customerLimit'] = $row['coupon_customerLimit']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['status'] = $row['coupon_status']; $appointments[$appointmentId]['bookings'][$bookingId]['coupon']['expirationDate'] = $row['coupon_expirationDate']; } if ($bookingId && $customerId) { $appointments[$appointmentId]['bookings'][$bookingId]['customer'] = [ 'id' => $customerId, 'firstName' => $row['customer_firstName'], 'lastName' => $row['customer_lastName'], 'email' => $row['customer_email'], 'note' => $row['customer_note'], 'phone' => $row['customer_phone'], 'gender' => $row['customer_gender'], 'status' => $row['customer_status'], 'type' => 'customer', ]; } if ($bookingId && $providerId) { $appointments[$appointmentId]['provider'] = [ 'id' => $providerId, 'firstName' => $row['provider_firstName'], 'lastName' => $row['provider_lastName'], 'email' => $row['provider_email'], 'note' => $row['provider_note'], 'description' => $row['provider_description'], 'phone' => $row['provider_phone'], 'gender' => $row['provider_gender'], 'timeZone' => !empty($row['provider_timeZone']) ? $row['provider_timeZone'] : null, 'type' => 'provider', ]; } if ($serviceId) { $appointments[$appointmentId]['service']['id'] = $row['service_id']; $appointments[$appointmentId]['service']['name'] = $row['service_name']; $appointments[$appointmentId]['service']['description'] = $row['service_description']; $appointments[$appointmentId]['service']['color'] = $row['service_color']; $appointments[$appointmentId]['service']['price'] = $row['service_price']; $appointments[$appointmentId]['service']['status'] = $row['service_status']; $appointments[$appointmentId]['service']['categoryId'] = $row['service_categoryId']; $appointments[$appointmentId]['service']['minCapacity'] = $row['service_minCapacity']; $appointments[$appointmentId]['service']['maxCapacity'] = $row['service_maxCapacity']; $appointments[$appointmentId]['service']['duration'] = $row['service_duration']; $appointments[$appointmentId]['service']['timeBefore'] = isset($row['service_timeBefore']) ? $row['service_timeBefore'] : null; $appointments[$appointmentId]['service']['timeAfter'] = isset($row['service_timeAfter']) ? $row['service_timeAfter'] : null; $appointments[$appointmentId]['service']['aggregatedPrice'] = isset($row['service_aggregatedPrice']) ? $row['service_aggregatedPrice'] : null; $appointments[$appointmentId]['service']['settings'] = isset($row['service_settings']) ? $row['service_settings'] : null; } } $collection = new Collection(); foreach ($appointments as $key => $value) { $collection->addItem( self::create($value), $key ); } return $collection; } } Booking/Event/CustomerBookingEventPeriodFactory.php 0000666 00000002157 15165637651 0016565 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Entity\Booking\Event\CustomerBookingEventPeriod; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class CustomerBookingEventPeriodFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class CustomerBookingEventPeriodFactory { /** * @param $data * * @return CustomerBookingEventPeriod */ public static function create($data) { $customerBookingEventPeriod = new CustomerBookingEventPeriod(); if (!empty($data['id'])) { $customerBookingEventPeriod->setId(new Id($data['id'])); } if (!empty($data['eventPeriodId'])) { $customerBookingEventPeriod->setEventPeriodId(new Id($data['eventPeriodId'])); } if (!empty($data['customerBookingId'])) { $customerBookingEventPeriod->setCustomerBookingId(new Id($data['customerBookingId'])); } return $customerBookingEventPeriod; } } Booking/Event/EventTicketFactory.php 0000666 00000003776 15165637651 0013543 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Event\EventTicket; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Json; /** * Class EventTicketFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class EventTicketFactory { /** * @param $data * * @return EventTicket * @throws InvalidArgumentException */ public static function create($data) { $eventTicket = new EventTicket(); if (isset($data['id'])) { $eventTicket->setId(new Id($data['id'])); } if (isset($data['eventId'])) { $eventTicket->setEventId(new Id($data['eventId'])); } if (isset($data['name'])) { $eventTicket->setName(new Name($data['name'])); } if (isset($data['enabled'])) { $eventTicket->setEnabled(new BooleanValueObject($data['enabled'])); } if (isset($data['price'])) { $eventTicket->setPrice(new Price($data['price'])); } if (isset($data['spots'])) { $eventTicket->setSpots(new IntegerValue($data['spots'])); } if (isset($data['dateRanges'])) { $eventTicket->setDateRanges(new Json($data['dateRanges'])); } if (isset($data['sold'])) { $eventTicket->setSold(new IntegerValue($data['sold'])); } if (!empty($data['translations'])) { $eventTicket->setTranslations(new Json($data['translations'])); } return $eventTicket; } } Booking/Event/RecurringFactory.php 0000666 00000003534 15165637651 0013246 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\Recurring; use AmeliaBooking\Domain\ValueObjects\String\Cycle; /** * Class RecurringFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class RecurringFactory { /** * @param $data * * @return Recurring * @throws InvalidArgumentException */ public static function create($data) { $recurring = new Recurring(new Cycle($data['cycle'])); if (isset($data['order'])) { $recurring->setOrder(new WholeNumber($data['order'])); } if (isset($data['cycleInterval'])) { $recurring->setCycleInterval(new WholeNumber($data['cycleInterval'])); } if (isset($data['monthlyRepeat'])) { $recurring->setMonthlyRepeat($data['monthlyRepeat']); } if (isset($data['monthlyOnRepeat']) && isset($data['monthlyOnDay'])) { $recurring->setMonthlyOnRepeat(strtolower($data['monthlyOnRepeat'])); $recurring->setMonthlyOnDay(strtolower($data['monthlyOnDay'])); } if (isset($data['monthDate'])) { $recurring->setMonthDate($data['monthDate'] ? new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['monthDate'])) : null); } if (isset($data['until'])) { $recurring->setUntil(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['until']))); } return $recurring; } } Booking/Event/EventFactory.php 0000666 00000064121 15165637651 0012366 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Event\Event; use AmeliaBooking\Domain\Entity\Entities; use AmeliaBooking\Domain\Entity\Gallery\GalleryImage; use AmeliaBooking\Domain\Factory\Booking\Appointment\CustomerBookingFactory; use AmeliaBooking\Domain\Factory\Coupon\CouponFactory; use AmeliaBooking\Domain\Factory\User\ProviderFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\ValueObjects\String\Color; use AmeliaBooking\Domain\ValueObjects\String\DepositType; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\EntityType; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class EventFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class EventFactory { /** * @param $data * * @return Event * @throws InvalidArgumentException */ public static function create($data) { $event = new Event(); if (isset($data['id'])) { $event->setId(new Id($data['id'])); } if (isset($data['name'])) { $event->setName(new Name($data['name'])); } if (isset($data['price'])) { $event->setPrice(new Price($data['price'])); } if (isset($data['parentId'])) { $event->setParentId(new Id($data['parentId'])); } if (!empty($data['bookingOpens'])) { $event->setBookingOpens(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['bookingOpens']))); } if (!empty($data['bookingCloses'])) { $event->setBookingCloses(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['bookingCloses']))); } if (!empty($data['bookingOpensRec'])) { $event->setBookingOpensRec($data['bookingOpensRec']); } if (!empty($data['bookingClosesRec'])) { $event->setBookingClosesRec($data['bookingClosesRec']); } if (!empty($data['ticketRangeRec'])) { $event->setTicketRangeRec($data['ticketRangeRec']); } if (isset($data['notifyParticipants'])) { $event->setNotifyParticipants($data['notifyParticipants']); } if (isset($data['status'])) { $event->setStatus(new BookingStatus($data['status'])); } if (isset($data['recurring']['cycle'], $data['recurring']['until'])) { $event->setRecurring(RecurringFactory::create($data['recurring'])); } if (isset($data['bringingAnyone'])) { $event->setBringingAnyone(new BooleanValueObject($data['bringingAnyone'])); } if (isset($data['bookMultipleTimes'])) { $event->setBookMultipleTimes(new BooleanValueObject($data['bookMultipleTimes'])); } if (isset($data['maxCapacity'])) { $event->setMaxCapacity(new IntegerValue($data['maxCapacity'])); } if (isset($data['maxCustomCapacity'])) { $event->setMaxCustomCapacity(new IntegerValue($data['maxCustomCapacity'])); } if (isset($data['description'])) { $event->setDescription(new Description($data['description'])); } if (!empty($data['locationId'])) { $event->setLocationId(new Id($data['locationId'])); } if (!empty($data['customLocation'])) { $event->setCustomLocation(new Name($data['customLocation'])); } if (isset($data['color'])) { $event->setColor(new Color($data['color'])); } if (isset($data['show'])) { $event->setShow(new BooleanValueObject($data['show'])); } if (isset($data['created'])) { $event->setCreated(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['created']))); } if (!empty($data['settings'])) { $event->setSettings(new Json($data['settings'])); } if (isset($data['deposit'])) { $event->setDeposit(new Price($data['deposit'])); } if (isset($data['depositPayment'])) { $event->setDepositPayment(new DepositType($data['depositPayment'])); } if (isset($data['fullPayment'])) { $event->setFullPayment(new BooleanValueObject($data['fullPayment'])); } if (isset($data['customPricing'])) { $event->setCustomPricing(new BooleanValueObject($data['customPricing'])); } if (isset($data['depositPerPerson'])) { $event->setDepositPerPerson(new BooleanValueObject($data['depositPerPerson'])); } if (isset($data['closeAfterMin'])) { $event->setCloseAfterMin(new IntegerValue($data['closeAfterMin'])); } if (isset($data['closeAfterMinBookings'])) { $event->setCloseAfterMinBookings(new BooleanValueObject($data['closeAfterMinBookings'])); } if (isset($data['aggregatedPrice'])) { $event->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice'])); } if (isset($data['maxExtraPeople'])) { $event->setMaxExtraPeople(new IntegerValue($data['maxExtraPeople'])); } $tickets = new Collection(); if (isset($data['customTickets'])) { foreach ($data['customTickets'] as $key => $value) { $tickets->addItem( EventTicketFactory::create($value), $key ); } } $event->setCustomTickets($tickets); $tags = new Collection(); if (isset($data['tags'])) { foreach ((array)$data['tags'] as $key => $value) { $tags->addItem( EventTagFactory::create($value), $key ); } } $event->setTags($tags); $bookings = new Collection(); if (isset($data['bookings'])) { foreach ((array)$data['bookings'] as $key => $value) { $bookings->addItem( CustomerBookingFactory::create($value), $key ); } } $event->setBookings($bookings); $periods = new Collection(); if (isset($data['periods'])) { foreach ((array)$data['periods'] as $key => $value) { $periods->addItem(EventPeriodFactory::create($value)); } } $event->setPeriods($periods); $gallery = new Collection(); if (!empty($data['gallery'])) { foreach ((array)$data['gallery'] as $image) { $galleryImage = new GalleryImage( new EntityType(Entities::EVENT), new Picture($image['pictureFullPath'], $image['pictureThumbPath']), new PositiveInteger($image['position']) ); if (!empty($image['id'])) { $galleryImage->setId(new Id($image['id'])); } if ($event->getId()) { $galleryImage->setEntityId($event->getId()); } $gallery->addItem($galleryImage); } } $event->setGallery($gallery); $coupons = new Collection(); if (!empty($data['coupons'])) { /** @var array $couponsList */ $couponsList = $data['coupons']; foreach ($couponsList as $couponKey => $coupon) { $coupons->addItem(CouponFactory::create($coupon), $couponKey); } } $event->setCoupons($coupons); $providers = new Collection(); if (!empty($data['providers'])) { /** @var array $providerList */ $providerList = $data['providers']; foreach ($providerList as $providerKey => $provider) { $providers->addItem(ProviderFactory::create($provider), $providerKey); } } if (!empty($data['organizerId'])) { $event->setOrganizerId(new Id($data['organizerId'])); } $event->setProviders($providers); if (!empty($data['zoomUserId'])) { $event->setZoomUserId(new Name($data['zoomUserId'])); } if (!empty($data['translations'])) { $event->setTranslations(new Json($data['translations'])); } return $event; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $events = []; foreach ($rows as $row) { $eventId = $row['event_id']; $eventPeriodId = isset($row['event_periodId']) ? $row['event_periodId'] : null; $galleryId = isset($row['gallery_id']) ? $row['gallery_id'] : null; $customerId = isset($row['customer_id']) ? $row['customer_id'] : null; $bookingId = isset($row['booking_id']) ? $row['booking_id'] : null; $bookingTicketId = isset($row['booking_ticket_id']) ? $row['booking_ticket_id'] : null; $paymentId = isset($row['payment_id']) ? $row['payment_id'] : null; $tagId = isset($row['event_tagId']) ? $row['event_tagId'] : null; $ticketId = isset($row['ticket_id']) ? $row['ticket_id'] : null; $providerId = isset($row['provider_id']) ? $row['provider_id'] : null; $couponId = isset($row['coupon_id']) ? $row['coupon_id'] : null; if (!array_key_exists($eventId, $events)) { $events[$eventId] = [ 'id' => $eventId, 'name' => $row['event_name'], 'status' => $row['event_status'], 'bookingOpens' => $row['event_bookingOpens'] && $row['event_bookingOpens'] !== '0000-00-00 00:00:00' ? DateTimeService::getCustomDateTimeFromUtc($row['event_bookingOpens']) : null, 'bookingCloses' => $row['event_bookingCloses'] && $row['event_bookingCloses'] !== '0000-00-00 00:00:00' ? DateTimeService::getCustomDateTimeFromUtc($row['event_bookingCloses']) : null, 'bookingOpensRec' => isset($row['event_bookingOpensRec']) ? $row['event_bookingOpensRec'] : null, 'bookingClosesRec' => isset($row['event_bookingClosesRec']) ? $row['event_bookingClosesRec'] : null, 'ticketRangeRec' => isset($row['event_ticketRangeRec']) ? $row['event_ticketRangeRec'] : null, 'recurring' => [ 'cycle' => $row['event_recurringCycle'], 'order' => $row['event_recurringOrder'], 'cycleInterval' => $row['event_recurringInterval'], 'monthlyRepeat' => isset($row['event_recurringMonthly']) ? $row['event_recurringMonthly'] : null, 'monthDate' => !empty($row['event_monthlyDate']) && $row['event_monthlyDate'] !== '0000-00-00 00:00:00' ? DateTimeService::getCustomDateTimeFromUtc($row['event_monthlyDate']) : null, 'monthlyOnRepeat' => isset($row['event_monthlyOnRepeat']) ? $row['event_monthlyOnRepeat'] : null, 'monthlyOnDay' => isset($row['event_monthlyOnDay']) ? $row['event_monthlyOnDay'] : null, 'until' => !empty($row['event_recurringUntil']) && $row['event_recurringUntil'] !== '0000-00-00 00:00:00' ? DateTimeService::getCustomDateTimeFromUtc($row['event_recurringUntil']) : null, ], 'bringingAnyone' => $row['event_bringingAnyone'], 'bookMultipleTimes' => $row['event_bookMultipleTimes'], 'maxCapacity' => $row['event_maxCapacity'], 'maxCustomCapacity' => $row['event_maxCustomCapacity'], 'maxExtraPeople' => $row['event_maxExtraPeople'], 'price' => $row['event_price'], 'description' => $row['event_description'], 'color' => $row['event_color'], 'show' => $row['event_show'], 'notifyParticipants' => $row['event_notifyParticipants'], 'locationId' => $row['event_locationId'], 'customLocation' => $row['event_customLocation'], 'parentId' => $row['event_parentId'], 'created' => $row['event_created'], 'settings' => isset($row['event_settings']) ? $row['event_settings'] : null, 'zoomUserId' => isset($row['event_zoomUserId']) ? $row['event_zoomUserId'] : null, 'organizerId' => isset($row['event_organizerId']) ? $row['event_organizerId'] : null, 'translations' => isset($row['event_translations']) ? $row['event_translations'] : null, 'deposit' => isset($row['event_deposit']) ? $row['event_deposit'] : null, 'depositPayment' => isset($row['event_depositPayment']) ? $row['event_depositPayment'] : null, 'depositPerPerson' => isset($row['event_depositPerPerson']) ? $row['event_depositPerPerson'] : null, 'fullPayment' => isset($row['event_fullPayment']) ? $row['event_fullPayment'] : null, 'customPricing' => isset($row['event_customPricing']) ? $row['event_customPricing'] : null, 'closeAfterMin' => isset($row['event_closeAfterMin']) ? $row['event_closeAfterMin'] : null, 'closeAfterMinBookings' => isset($row['event_closeAfterMinBookings']) ? $row['event_closeAfterMinBookings'] : null, 'aggregatedPrice' => isset($row['event_aggregatedPrice']) ? $row['event_aggregatedPrice'] : null, ]; } if ($galleryId) { $events[$eventId]['gallery'][$galleryId]['id'] = $row['gallery_id']; $events[$eventId]['gallery'][$galleryId]['pictureFullPath'] = $row['gallery_picture_full']; $events[$eventId]['gallery'][$galleryId]['pictureThumbPath'] = $row['gallery_picture_thumb']; $events[$eventId]['gallery'][$galleryId]['position'] = $row['gallery_position']; } if ($providerId) { $events[$eventId]['providers'][$providerId] = [ 'id' => $providerId, 'firstName' => $row['provider_firstName'], 'lastName' => $row['provider_lastName'], 'email' => $row['provider_email'], 'note' => $row['provider_note'], 'description' => $row['provider_description'], 'phone' => $row['provider_phone'], 'pictureFullPath' => isset($row['provider_pictureFullPath']) ? $row['provider_pictureFullPath'] : null, 'pictureThumbPath' => isset($row['provider_pictureFullPath']) ? $row['provider_pictureThumbPath'] : null, 'type' => 'provider', 'googleCalendar' => [ 'id' => isset($row['google_calendar_id']) ? $row['google_calendar_id'] : null, 'token' => isset($row['google_calendar_token']) ? $row['google_calendar_token'] : null, 'calendarId' => isset($row['google_calendar_calendar_id']) ? $row['google_calendar_calendar_id'] : null ], 'translations' => $row['provider_translations'], 'timeZone' => isset($row['provider_timeZone']) ? $row['provider_timeZone'] : null, 'outlookCalendar' => [ 'id' => isset($row['outlook_calendar_id']) ? $row['outlook_calendar_id']: null, 'token' => isset($row['outlook_calendar_token']) ? $row['outlook_calendar_token'] : null, 'calendarId' => isset($row['outlook_calendar_calendar_id']) ? $row['outlook_calendar_calendar_id'] : null ], ]; } if ($eventPeriodId && !isset($events[$eventId]['periods'][$eventPeriodId])) { $zoomMeetingJson = !empty($row['event_periodZoomMeeting']) ? json_decode($row['event_periodZoomMeeting'], true) : null; $events[$eventId]['periods'][$eventPeriodId] = [ 'id' => $eventPeriodId, 'eventId' => $eventId, 'periodStart' => DateTimeService::getCustomDateTimeFromUtc($row['event_periodStart']), 'periodEnd' => DateTimeService::getCustomDateTimeFromUtc($row['event_periodEnd']), 'zoomMeeting' => [ 'id' => $zoomMeetingJson ? $zoomMeetingJson['id'] : null, 'startUrl' => $zoomMeetingJson ? $zoomMeetingJson['startUrl'] : null, 'joinUrl' => $zoomMeetingJson ? $zoomMeetingJson['joinUrl'] : null, ], 'lessonSpace' => !empty($row['event_periodLessonSpace']) ? $row['event_periodLessonSpace'] : null, 'bookings' => [], 'googleCalendarEventId' => !empty($row['event_googleCalendarEventId']) ? $row['event_googleCalendarEventId'] : null, 'googleMeetUrl' => !empty($row['event_googleMeetUrl']) ? $row['event_googleMeetUrl'] : null, 'outlookCalendarEventId' => !empty($row['event_outlookCalendarEventId']) ? $row['event_outlookCalendarEventId'] : null ]; } if ($tagId && !isset($events[$eventId]['tags'][$tagId])) { $events[$eventId]['tags'][$tagId] = [ 'id' => $tagId, 'eventId' => $eventId, 'name' => $row['event_tagName'] ]; } if ($bookingId && !isset($events[$eventId]['bookings'][$bookingId])) { $events[$eventId]['bookings'][$bookingId] = [ 'id' => $bookingId, 'appointmentId' => null, 'customerId' => $row['booking_customerId'], 'status' => $row['booking_status'], 'price' => $row['booking_price'], 'persons' => $row['booking_persons'], 'customFields' => !empty($row['booking_customFields']) ? $row['booking_customFields'] : null, 'info' => !empty($row['booking_info']) ? $row['booking_info'] : null, 'utcOffset' => isset($row['booking_utcOffset']) ? $row['booking_utcOffset'] : null, 'aggregatedPrice' => isset($row['booking_aggregatedPrice']) ? $row['booking_aggregatedPrice'] : null, 'token' => isset($row['booking_token']) ? $row['booking_token'] : null, ]; } if ($bookingTicketId && !isset($events[$eventId]['bookings'][$bookingId]['ticketsData'][$bookingTicketId])) { $events[$eventId]['bookings'][$bookingId]['ticketsData'][$bookingTicketId] = [ 'id' => $bookingTicketId, 'eventTicketId' => $row['booking_ticket_eventTicketId'], 'customerBookingId' => $bookingId, 'persons' => $row['booking_ticket_persons'], 'price' => $row['booking_ticket_price'], ]; } if ($ticketId && !isset($events[$eventId]['customTickets'][$ticketId])) { $events[$eventId]['customTickets'][$ticketId] = [ 'id' => $ticketId, 'eventId' => $eventId, 'name' => $row['ticket_name'], 'enabled' => $row['ticket_enabled'], 'spots' => $row['ticket_spots'], 'price' => $row['ticket_price'], 'dateRanges' => $row['ticket_dateRanges'], 'translations' => $row['ticket_translations'], ]; } if ($bookingId && !isset($events[$eventId]['periods'][$eventPeriodId]['bookings'][$bookingId])) { $events[$eventId]['periods'][$eventPeriodId]['bookings'][$bookingId] = [ 'id' => $bookingId, 'appointmentId' => null, 'customerId' => $row['booking_customerId'], 'status' => $row['booking_status'], 'price' => $row['booking_price'], 'persons' => $row['booking_persons'], 'customFields' => !empty($row['booking_customFields']) ? $row['booking_customFields'] : null, 'info' => !empty($row['booking_info']) ? $row['booking_info'] : null, 'utcOffset' => isset($row['booking_utcOffset']) ? $row['booking_utcOffset'] : null ]; } if ($bookingId && $paymentId) { $events[$eventId]['bookings'][$bookingId]['payments'][$paymentId] = [ 'id' => $paymentId, 'customerBookingId' => $bookingId, 'status' => $row['payment_status'], 'dateTime' => DateTimeService::getCustomDateTimeFromUtc($row['payment_dateTime']), 'gateway' => $row['payment_gateway'], 'gatewayTitle' => $row['payment_gatewayTitle'], 'transactionId' => $row['payment_transactionId'], 'parentId' => $row['payment_parentId'], 'amount' => $row['payment_amount'], 'data' => $row['payment_data'], 'wcOrderId' => !empty($row['payment_wcOrderId']) ? $row['payment_wcOrderId'] : null, ]; } if ($bookingId && $customerId) { $events[$eventId]['bookings'][$bookingId]['customer'] = [ 'id' => $customerId, 'firstName' => $row['customer_firstName'], 'lastName' => $row['customer_lastName'], 'email' => $row['customer_email'], 'note' => $row['customer_note'], 'phone' => $row['customer_phone'], 'gender' => $row['customer_gender'], 'birthday' => !empty($row['customer_birthday']) ? $row['customer_birthday'] : null, 'type' => 'customer', ]; } if ($bookingId && $couponId) { $events[$eventId]['bookings'][$bookingId]['coupon']['id'] = $couponId; $events[$eventId]['bookings'][$bookingId]['coupon']['code'] = $row['coupon_code']; $events[$eventId]['bookings'][$bookingId]['coupon']['discount'] = $row['coupon_discount']; $events[$eventId]['bookings'][$bookingId]['coupon']['deduction'] = $row['coupon_deduction']; $events[$eventId]['bookings'][$bookingId]['coupon']['limit'] = $row['coupon_limit']; $events[$eventId]['bookings'][$bookingId]['coupon']['customerLimit'] = $row['coupon_customerLimit']; $events[$eventId]['bookings'][$bookingId]['coupon']['status'] = $row['coupon_status']; } if ($couponId) { $events[$eventId]['coupons'][$couponId]['id'] = $couponId; $events[$eventId]['coupons'][$couponId]['code'] = $row['coupon_code']; $events[$eventId]['coupons'][$couponId]['discount'] = $row['coupon_discount']; $events[$eventId]['coupons'][$couponId]['deduction'] = $row['coupon_deduction']; $events[$eventId]['coupons'][$couponId]['limit'] = $row['coupon_limit']; $events[$eventId]['coupons'][$couponId]['customerLimit'] = $row['coupon_customerLimit']; $events[$eventId]['coupons'][$couponId]['status'] = $row['coupon_status']; } } $collection = new Collection(); foreach ($events as $key => $value) { $collection->addItem( self::create($value), $key ); } return $collection; } } Booking/Event/EventTagFactory.php 0000666 00000002006 15165637651 0013014 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Entity\Booking\Event\EventTag; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class EventTagFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class EventTagFactory { /** * @param $data * * @return EventTag * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function create($data) { $eventTag = new EventTag(); if (!empty($data['id'])) { $eventTag->setId(new Id($data['id'])); } if (!empty($data['eventId'])) { $eventTag->setEventId(new Id($data['eventId'])); } if (isset($data['name'])) { $eventTag->setName(new Name($data['name'])); } return $eventTag; } } Booking/Event/EventPeriodFactory.php 0000666 00000004634 15165637651 0013534 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Event\EventPeriod; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Url; use AmeliaBooking\Domain\Factory\Zoom\ZoomFactory; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class EventPeriodFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class EventPeriodFactory { /** * @param $data * * @return EventPeriod * @throws InvalidArgumentException */ public static function create($data) { $eventPeriod = new EventPeriod(); if (!empty($data['id'])) { $eventPeriod->setId(new Id($data['id'])); } if (!empty($data['eventId'])) { $eventPeriod->setEventId(new Id($data['eventId'])); } if (isset($data['periodStart'])) { $eventPeriod->setPeriodStart(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['periodStart']))); } if (isset($data['periodEnd'])) { $eventPeriod->setPeriodEnd(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['periodEnd']))); } if (!empty($data['zoomMeeting']) && !empty($data['zoomMeeting']['id'])) { $zoomMeeting = ZoomFactory::create( $data['zoomMeeting'] ); $eventPeriod->setZoomMeeting($zoomMeeting); } if (isset($data['lessonSpace']) && !empty($data['lessonSpace'])) { $eventPeriod->setLessonSpace($data['lessonSpace']); } if (!empty($data['googleCalendarEventId'])) { $eventPeriod->setGoogleCalendarEventId(new Token($data['googleCalendarEventId'])); } if (!empty($data['googleMeetUrl'])) { $eventPeriod->setGoogleMeetUrl($data['googleMeetUrl']); } if (!empty($data['outlookCalendarEventId'])) { $eventPeriod->setOutlookCalendarEventId(new Label($data['outlookCalendarEventId'])); } return $eventPeriod; } } Booking/Event/CustomerBookingEventTicketFactory.php 0000666 00000003143 15165637651 0016562 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Booking\Event; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Booking\Event\CustomerBookingEventTicket; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; /** * Class CustomerBookingEventTicketFactory * * @package AmeliaBooking\Domain\Factory\Booking\Event */ class CustomerBookingEventTicketFactory { /** * @param $data * * @return CustomerBookingEventTicket * @throws InvalidArgumentException */ public static function create($data) { $customerBookingEventTicket = new CustomerBookingEventTicket(); if (!empty($data['id'])) { $customerBookingEventTicket->setId(new Id($data['id'])); } if (!empty($data['eventTicketId'])) { $customerBookingEventTicket->setEventTicketId(new Id($data['eventTicketId'])); } if (!empty($data['customerBookingId'])) { $customerBookingEventTicket->setCustomerBookingId(new Id($data['customerBookingId'])); } if (!empty($data['persons'])) { $customerBookingEventTicket->setPersons(new IntegerValue($data['persons'])); } if (isset($data['price'])) { $customerBookingEventTicket->setPrice(new Price($data['price'])); } return $customerBookingEventTicket; } } Payment/PaymentGatewayFactory.php 0000666 00000001311 15165637651 0013200 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Payment; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Payment\PaymentGateway; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class PaymentGatewayFactory * * @package AmeliaBooking\Domain\Factory\Payment */ class PaymentGatewayFactory { /** * @param $data * * @return PaymentGateway * @throws InvalidArgumentException */ public static function create($data) { return new PaymentGateway( new Name($data['name']) ); } } Payment/PaymentFactory.php 0000666 00000007160 15165637651 0011666 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Payment; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Payment\PaymentGateway; use AmeliaBooking\Domain\Entity\Payment\Payment; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\PaymentStatus; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\PaymentData; use AmeliaBooking\Domain\ValueObjects\String\Url; use AmeliaBooking\Infrastructure\WP\HelperService\HelperService; use AmeliaBooking\Infrastructure\WP\Integrations\WooCommerce\WooCommerceService; /** * Class PaymentFactory * * @package AmeliaBooking\Domain\Factory\Payment */ class PaymentFactory { /** * @param $data * * @return Payment * @throws InvalidArgumentException */ public static function create($data) { if (isset($data['data']) && !is_string($data['data'])) { $data['data'] = json_encode($data['data'], true); } $payment = new Payment( new Id($data['customerBookingId']), new Price($data['amount']), new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['dateTime'])), new PaymentStatus($data['status']), new PaymentGateway(new Name($data['gateway'])), new PaymentData(isset($data['data']) ? $data['data'] : '') ); if (isset($data['id'])) { $payment->setId(new Id($data['id'])); } if (!empty($data['gatewayTitle'])) { $payment->setGatewayTitle(new Name($data['gatewayTitle'])); } if (!empty($data['packageCustomerId'])) { $payment->setPackageCustomerId(new Id($data['packageCustomerId'])); } if (!empty($data['parentId'])) { $payment->setParentId(new Id($data['parentId'])); } if (!empty($data['entity'])) { $payment->setEntity(new Name($data['entity'])); } if (!empty($data['actionsCompleted'])) { $payment->setActionsCompleted(new BooleanValueObject($data['actionsCompleted'])); } if (!empty($data['created'])) { $payment->setCreated(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['created']))); } if (!empty($data['wcOrderId']) && WooCommerceService::isEnabled()) { $payment->setWcOrderId(new Id($data['wcOrderId'])); if ($wcOrderUrl = HelperService::getWooCommerceOrderUrl($data['wcOrderId'])) { $payment->setWcOrderUrl(new Url($wcOrderUrl)); } if ($wcOrderItemValues = HelperService::getWooCommerceOrderItemAmountValues($data['wcOrderId'])) { if (!empty($wcOrderItemValues[0]['coupon'])) { $payment->setWcItemCouponValue(new Price($wcOrderItemValues[0]['coupon'] < 0 ? 0 : $wcOrderItemValues[0]['coupon'])); } if (!empty($wcOrderItemValues[0]['tax'])) { $payment->setWcItemTaxValue(new Price($wcOrderItemValues[0]['tax'])); } } } if (!empty($data['transactionId'])) { $payment->setTransactionId($data['transactionId']); } return $payment; } } Settings/SettingsFactory.php 0000666 00000010242 15165637651 0012227 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Settings; use AmeliaBooking\Domain\Entity\Settings\GeneralSettings; use AmeliaBooking\Domain\Entity\Settings\LessonSpaceSettings; use AmeliaBooking\Domain\Entity\Settings\PaymentSettings; use AmeliaBooking\Domain\Entity\Settings\Settings; use AmeliaBooking\Domain\Entity\Settings\ZoomSettings; use AmeliaBooking\Domain\ValueObjects\Json; /** * Class SettingsFactory * * @package AmeliaBooking\Domain\Factory\Settings */ class SettingsFactory { /** * @param Json $entityJsonData * @param array $globalSettings * * @return Settings */ public static function create($entityJsonData, $globalSettings) { $entitySettings = new Settings(); $generalSettings = new GeneralSettings(); $zoomSettings = new ZoomSettings(); $paymentSettings = new PaymentSettings(); $lessonSpaceSetings = new LessonSpaceSettings(); $data = $entityJsonData ? json_decode($entityJsonData->getValue(), true) : []; $isOldEntitySettings = !isset($data['activation']['version']); if (isset($data['general']['defaultAppointmentStatus'])) { $generalSettings->setDefaultAppointmentStatus($data['general']['defaultAppointmentStatus']); } else { $generalSettings->setDefaultAppointmentStatus($globalSettings['general']['defaultAppointmentStatus']); } if (isset($data['general']['minimumTimeRequirementPriorToBooking'])) { $generalSettings->setMinimumTimeRequirementPriorToBooking( $data['general']['minimumTimeRequirementPriorToBooking'] ); } else { $generalSettings->setMinimumTimeRequirementPriorToBooking( $globalSettings['general']['minimumTimeRequirementPriorToBooking'] ); } if (isset($data['general']['minimumTimeRequirementPriorToCanceling'])) { $generalSettings->setMinimumTimeRequirementPriorToCanceling( $data['general']['minimumTimeRequirementPriorToCanceling'] ); } else { $generalSettings->setMinimumTimeRequirementPriorToCanceling( $globalSettings['general']['minimumTimeRequirementPriorToCanceling'] ); } if (isset($data['general']['minimumTimeRequirementPriorToRescheduling'])) { $generalSettings->setMinimumTimeRequirementPriorToRescheduling( $data['general']['minimumTimeRequirementPriorToRescheduling'] ); } else { $generalSettings->setMinimumTimeRequirementPriorToRescheduling( $globalSettings['general']['minimumTimeRequirementPriorToRescheduling'] ); } if ($isOldEntitySettings && !isset($globalSettings['general']['minimumTimeRequirementPriorToCanceling'])) { $generalSettings->setMinimumTimeRequirementPriorToRescheduling( $generalSettings->getMinimumTimeRequirementPriorToCanceling() ); } if (!empty($data['general']['numberOfDaysAvailableForBooking'])) { $generalSettings->setNumberOfDaysAvailableForBooking( $data['general']['numberOfDaysAvailableForBooking'] ); } else { $generalSettings->setNumberOfDaysAvailableForBooking( $globalSettings['general']['numberOfDaysAvailableForBooking'] ); } if (isset($data['zoom']['enabled'])) { $zoomSettings->setEnabled($data['zoom']['enabled']); } else { $zoomSettings->setEnabled($globalSettings['zoom']['enabled']); } if (isset($data['lessonSpace']['enabled'])) { $lessonSpaceSetings->setEnabled($data['lessonSpace']['enabled']); } else { $lessonSpaceSetings->setEnabled($globalSettings['lessonSpace']['enabled']); } $entitySettings->setGeneralSettings($generalSettings); $entitySettings->setZoomSettings($zoomSettings); $entitySettings->setLessonSpaceSettings($lessonSpaceSetings); return $entitySettings; } } Cache/CacheFactory.php 0000666 00000002113 15165637651 0010633 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Cache; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Cache\Cache; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class CacheFactory * * @package AmeliaBooking\Domain\Factory\Cache */ class CacheFactory { /** * @param $data * * @return Cache * @throws InvalidArgumentException */ public static function create($data) { $cache = new Cache( new Name($data['name']) ); if (isset($data['id'])) { $cache->setId(new Id($data['id'])); } if (!empty($data['paymentId'])) { $cache->setPaymentId(new Id($data['paymentId'])); } if (!empty($data['data'])) { $cache->setData(new Json($data['data'])); } return $cache; } } Bookable/Service/PackageCustomerFactory.php 0000666 00000006030 15165637651 0015022 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageCustomer; use AmeliaBooking\Domain\Factory\Payment\PaymentFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\String\BookingStatus; /** * Class PackageCustomerFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class PackageCustomerFactory { /** * @param $data * * @return PackageCustomer * @throws InvalidArgumentException */ public static function create($data) { /** @var PackageCustomer $packageCustomer */ $packageCustomer = new PackageCustomer(); if (isset($data['id'])) { $packageCustomer->setId(new Id($data['id'])); } if (isset($data['packageId'])) { $packageCustomer->setPackageId(new Id($data['packageId'])); } if (isset($data['customerId'])) { $packageCustomer->setCustomerId(new Id($data['customerId'])); } if (isset($data['price'])) { $packageCustomer->setPrice(new Price($data['price'])); } $payments = new Collection(); if (!empty($data['payments'])) { /** @var array $paymentsList */ $paymentsList = $data['payments']; foreach ($paymentsList as $paymentKey => $payment) { $payments->addItem(PaymentFactory::create($payment), $paymentKey); } } $packageCustomer->setPayments($payments); if (!empty($data['end'])) { $packageCustomer->setEnd( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['end'])) ); } if (!empty($data['start'])) { $packageCustomer->setStart( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['start'])) ); } if (!empty($data['purchased'])) { $packageCustomer->setPurchased( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['purchased'])) ); } if (!empty($data['status'])) { $packageCustomer->setStatus( new BookingStatus($data['status']) ); } if (isset($data['bookingsCount'])) { $packageCustomer->setBookingsCount(new WholeNumber($data['bookingsCount'])); } if (isset($data['couponId'])) { $packageCustomer->setCouponId(new Id($data['couponId'])); } return $packageCustomer; } } Bookable/Service/CategoryFactory.php 0000666 00000003037 15165637651 0013526 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Bookable\Service\Category; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class CategoryFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class CategoryFactory { /** * @param array $data * * @return Category * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function create($data) { $category = new Category( new Status($data['status']), new Name($data['name']), new PositiveInteger($data['position']) ); if (isset($data['id'])) { $category->setId(new Id($data['id'])); } if (isset($data['serviceList'])) { $services = []; /** @var array $serviceList */ $serviceList = $data['serviceList']; foreach ($serviceList as $service) { $services[] = ServiceFactory::create($service); } $category->setServiceList(new Collection($services)); } if (isset($data['translations'])) { $category->setTranslations(new Json($data['translations'])); } return $category; } } Bookable/Service/ExtraFactory.php 0000666 00000003416 15165637651 0013035 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Extra; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Duration; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class ExtraFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class ExtraFactory { /** * @param array $data * * @return Extra * @throws InvalidArgumentException */ public static function create($data) { $extra = new Extra( new Name($data['name']), new Description($data['description']), new Price($data['price']), new PositiveInteger($data['maxQuantity']), new PositiveInteger($data['position']) ); if (isset($data['id'])) { $extra->setId(new Id($data['id'])); } if (!empty($data['duration'])) { $extra->setDuration(new Duration($data['duration'])); } if (isset($data['serviceId'])) { $extra->setServiceId(new Id($data['serviceId'])); } if (isset($data['aggregatedPrice'])) { $extra->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice'])); } if (isset($data['translations'])) { $extra->setTranslations(new Json($data['translations'])); } return $extra; } } Bookable/Service/ServiceFactory.php 0000666 00000032204 15165637651 0013347 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Service; use AmeliaBooking\Domain\Entity\Entities; use AmeliaBooking\Domain\Entity\Gallery\GalleryImage; use AmeliaBooking\Domain\Factory\Coupon\CouponFactory; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Duration; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\PositiveDuration; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Cycle; use AmeliaBooking\Domain\ValueObjects\String\DepositType; use AmeliaBooking\Domain\ValueObjects\String\EntityType; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Priority; use AmeliaBooking\Domain\ValueObjects\String\Color; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Name; /** * Class ServiceFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class ServiceFactory { /** * @param $data * * @return Service * @throws InvalidArgumentException */ public static function create($data) { $service = new Service(); if (isset($data['id'])) { $service->setId(new Id($data['id'])); } if (isset($data['name'])) { $service->setName(new Name($data['name'])); } if (isset($data['price'])) { $service->setPrice(new Price($data['price'])); } if (isset($data['status'])) { $service->setStatus(new Status($data['status'])); } if (isset($data['categoryId'])) { $service->setCategoryId(new Id($data['categoryId'])); } if (isset($data['minCapacity'])) { $service->setMinCapacity(new IntegerValue($data['minCapacity'])); } if (isset($data['maxCapacity'])) { $service->setMaxCapacity(new IntegerValue($data['maxCapacity'])); } if (isset($data['duration'])) { $service->setDuration(new PositiveDuration($data['duration'])); } if (isset($data['description'])) { $service->setDescription(new Description($data['description'])); } if (isset($data['color'])) { $service->setColor(new Color($data['color'])); } if (!empty($data['timeBefore'])) { $service->setTimeBefore(new Duration($data['timeBefore'])); } if (!empty($data['timeAfter'])) { $service->setTimeAfter(new Duration($data['timeAfter'])); } if (isset($data['bringingAnyone'])) { $service->setBringingAnyone(new BooleanValueObject($data['bringingAnyone'])); } if (isset($data['aggregatedPrice'])) { $service->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice'])); } if (!empty($data['priority'])) { $service->setPriority(new Priority($data['priority'])); } if (!empty($data['pictureFullPath']) && !empty($data['pictureThumbPath'])) { $service->setPicture(new Picture($data['pictureFullPath'], $data['pictureThumbPath'])); } if (!empty($data['position'])) { $service->setPosition(new PositiveInteger($data['position'])); } if (isset($data['show'])) { $service->setShow(new BooleanValueObject($data['show'])); } if (!empty($data['settings'])) { $service->setSettings(new Json($data['settings'])); } if (!empty($data['recurringCycle'])) { $service->setRecurringCycle(new Cycle($data['recurringCycle'])); } if (!empty($data['recurringSub'])) { $service->setRecurringSub(new Name($data['recurringSub'])); } if (isset($data['recurringPayment'])) { $service->setRecurringPayment(new WholeNumber($data['recurringPayment'])); } if (isset($data['translations'])) { $service->setTranslations(new Json($data['translations'])); } if (!empty($data['customPricing'])) { $service->setCustomPricing(new Json($data['customPricing'])); } if (isset($data['limitPerCustomer'])) { $service->setLimitPerCustomer(new Json($data['limitPerCustomer'])); } if (isset($data['deposit'])) { $service->setDeposit(new Price($data['deposit'])); } if (isset($data['depositPayment'])) { $service->setDepositPayment(new DepositType($data['depositPayment'])); } if (isset($data['depositPerPerson'])) { $service->setDepositPerPerson(new BooleanValueObject($data['depositPerPerson'])); } if (isset($data['mandatoryExtra'])) { $service->setMandatoryExtra(new BooleanValueObject($data['mandatoryExtra'])); } if (!empty($data['minSelectedExtras'])) { $service->setMinSelectedExtras(new IntegerValue($data['minSelectedExtras'])); } if (isset($data['fullPayment'])) { $service->setFullPayment(new BooleanValueObject($data['fullPayment'])); } $gallery = new Collection(); if (!empty($data['gallery'])) { foreach ((array)$data['gallery'] as $image) { $galleryImage = new GalleryImage( new EntityType(Entities::SERVICE), new Picture($image['pictureFullPath'], $image['pictureThumbPath']), new PositiveInteger($image['position']) ); if (!empty($image['id'])) { $galleryImage->setId(new Id($image['id'])); } if ($service->getId()) { $galleryImage->setEntityId($service->getId()); } $gallery->addItem($galleryImage); } } $service->setGallery($gallery); $extras = new Collection(); if (!empty($data['extras'])) { /** @var array $extrasList */ $extrasList = $data['extras']; foreach ($extrasList as $extraKey => $extra) { $extras->addItem(ExtraFactory::create($extra), $extraKey); } } $service->setExtras($extras); $coupons = new Collection(); if (!empty($data['coupons'])) { /** @var array $couponsList */ $couponsList = $data['coupons']; foreach ($couponsList as $couponKey => $coupon) { $coupons->addItem(CouponFactory::create($coupon), $couponKey); } } $service->setCoupons($coupons); if (isset($data['maxExtraPeople'])) { $service->setMaxExtraPeople(new IntegerValue($data['maxExtraPeople'])); } return $service; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $services = []; foreach ($rows as $row) { $serviceId = $row['service_id']; $extraId = $row['extra_id']; $galleryId = isset($row['gallery_id']) ? $row['gallery_id'] : null; $services[$serviceId]['id'] = $row['service_id']; $services[$serviceId]['name'] = $row['service_name']; $services[$serviceId]['description'] = $row['service_description']; $services[$serviceId]['color'] = $row['service_color']; $services[$serviceId]['price'] = $row['service_price']; $services[$serviceId]['status'] = $row['service_status']; $services[$serviceId]['categoryId'] = $row['service_categoryId']; $services[$serviceId]['minCapacity'] = $row['service_minCapacity']; $services[$serviceId]['maxCapacity'] = $row['service_maxCapacity']; $services[$serviceId]['maxExtraPeople'] = isset($row['service_maxExtraPeople']) ? $row['service_maxExtraPeople'] : null; $services[$serviceId]['duration'] = $row['service_duration']; $services[$serviceId]['timeAfter'] = $row['service_timeAfter']; $services[$serviceId]['timeBefore'] = $row['service_timeBefore']; $services[$serviceId]['bringingAnyone'] = $row['service_bringingAnyone']; $services[$serviceId]['pictureFullPath'] = $row['service_picture_full']; $services[$serviceId]['pictureThumbPath'] = $row['service_picture_thumb']; $services[$serviceId]['position'] = isset($row['service_position']) ? $row['service_position'] : 0; $services[$serviceId]['show'] = isset($row['service_show']) ? $row['service_show'] : 0; $services[$serviceId]['aggregatedPrice'] = isset($row['service_aggregatedPrice']) ? $row['service_aggregatedPrice'] : 0; $services[$serviceId]['settings'] = isset($row['service_settings']) ? $row['service_settings'] : null; $services[$serviceId]['recurringCycle'] = isset($row['service_recurringCycle']) ? $row['service_recurringCycle'] : null; $services[$serviceId]['recurringSub'] = isset($row['service_recurringSub']) ? $row['service_recurringSub'] : null; $services[$serviceId]['recurringPayment'] = isset($row['service_recurringPayment']) ? $row['service_recurringPayment'] : null; $services[$serviceId]['translations'] = isset($row['service_translations']) ? $row['service_translations'] : null; $services[$serviceId]['customPricing'] = isset($row['service_customPricing']) ? $row['service_customPricing'] : null; $services[$serviceId]['limitPerCustomer'] = isset($row['service_limitPerCustomer']) ? $row['service_limitPerCustomer'] : null; $services[$serviceId]['deposit'] = isset($row['service_deposit']) ? $row['service_deposit'] : null; $services[$serviceId]['depositPayment'] = isset($row['service_depositPayment']) ? $row['service_depositPayment'] : null; $services[$serviceId]['depositPerPerson'] = isset($row['service_depositPerPerson']) ? $row['service_depositPerPerson'] : null; $services[$serviceId]['mandatoryExtra'] = isset($row['service_mandatoryExtra']) ? $row['service_mandatoryExtra'] : null; $services[$serviceId]['minSelectedExtras'] = isset($row['service_minSelectedExtras']) ? $row['service_minSelectedExtras'] : null; $services[$serviceId]['fullPayment'] = isset($row['service_fullPayment']) ? $row['service_fullPayment'] : null; if ($extraId) { $services[$serviceId]['extras'][$extraId]['id'] = $row['extra_id']; $services[$serviceId]['extras'][$extraId]['name'] = $row['extra_name']; $services[$serviceId]['extras'][$extraId]['description'] = isset($row['extra_description']) ? $row['extra_description'] : null; $services[$serviceId]['extras'][$extraId]['price'] = $row['extra_price']; $services[$serviceId]['extras'][$extraId]['maxQuantity'] = $row['extra_maxQuantity']; $services[$serviceId]['extras'][$extraId]['duration'] = $row['extra_duration']; $services[$serviceId]['extras'][$extraId]['position'] = $row['extra_position']; $services[$serviceId]['extras'][$extraId]['aggregatedPrice'] = $row['extra_aggregatedPrice']; $services[$serviceId]['extras'][$extraId]['translations'] = $row['extra_translations']; } if ($galleryId) { $services[$serviceId]['gallery'][$galleryId]['id'] = $row['gallery_id']; $services[$serviceId]['gallery'][$galleryId]['pictureFullPath'] = $row['gallery_picture_full']; $services[$serviceId]['gallery'][$galleryId]['pictureThumbPath'] = $row['gallery_picture_thumb']; $services[$serviceId]['gallery'][$galleryId]['position'] = $row['gallery_position']; } } $servicesCollection = new Collection(); foreach ($services as $serviceKey => $serviceArray) { if (!array_key_exists('extras', $serviceArray)) { $serviceArray['extras'] = []; } if (!array_key_exists('gallery', $serviceArray)) { $serviceArray['gallery'] = []; } $servicesCollection->addItem( self::create($serviceArray), $serviceKey ); } return $servicesCollection; } } Bookable/Service/PackageCustomerServiceFactory.php 0000666 00000012261 15165637651 0016346 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageCustomer; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageCustomerService; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; /** * Class PackageCustomerFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class PackageCustomerServiceFactory { /** * @param $data * * @return PackageCustomerService * @throws InvalidArgumentException */ public static function create($data) { /** @var PackageCustomerService $packageCustomerService */ $packageCustomerService = new PackageCustomerService(); if (isset($data['id'])) { $packageCustomerService->setId(new Id($data['id'])); } if (isset($data['packageCustomer'])) { /** @var PackageCustomer $packageCustomer */ $packageCustomer = PackageCustomerFactory::create($data['packageCustomer']); $packageCustomerService->setPackageCustomer($packageCustomer); } if (isset($data['serviceId'])) { $packageCustomerService->setServiceId(new Id($data['serviceId'])); } if (isset($data['providerId'])) { $packageCustomerService->setProviderId(new Id($data['providerId'])); } if (isset($data['locationId'])) { $packageCustomerService->setLocationId(new Id($data['locationId'])); } if (isset($data['bookingsCount'])) { $packageCustomerService->setBookingsCount(new WholeNumber($data['bookingsCount'])); } return $packageCustomerService; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $packagesCustomersServices = []; foreach ($rows as $row) { $packageCustomerServiceId = $row['package_customer_service_id']; if (!array_key_exists($packageCustomerServiceId, $packagesCustomersServices)) { $packagesCustomersServices[$packageCustomerServiceId] = [ 'id' => $packageCustomerServiceId, 'serviceId' => $row['package_customer_service_serviceId'], 'providerId' => $row['package_customer_service_providerId'], 'locationId' => $row['package_customer_service_locationId'], 'bookingsCount' => $row['package_customer_service_bookingsCount'], 'packageCustomer' => [ 'id' => $row['package_customer_id'], 'customerId' => $row['package_customer_customerId'], 'packageId' => $row['package_customer_packageId'], 'price' => $row['package_customer_price'], 'start' => $row['package_customer_start'], 'end' => $row['package_customer_end'], 'purchased' => DateTimeService::getCustomDateTimeFromUtc( $row['package_customer_purchased'] ), 'status' => $row['package_customer_status'], 'bookingsCount' => $row['package_customer_bookingsCount'], 'couponId' => $row['package_customer_couponId'], ] ]; } if (!empty($row['payment_id'])) { $packagesCustomersServices[$packageCustomerServiceId]['packageCustomer']['payments'][$row['payment_id']] = [ 'id' => $row['payment_id'], 'customerBookingId' => null, 'packageCustomerId' => $row['payment_packageCustomerId'], 'status' => $row['payment_status'], 'dateTime' => DateTimeService::getCustomDateTimeFromUtc($row['payment_dateTime']), 'gateway' => $row['payment_gateway'], 'gatewayTitle' => $row['payment_gatewayTitle'], 'transactionId' => $row['payment_transactionId'], 'parentId' => $row['payment_parentId'], 'amount' => $row['payment_amount'], 'data' => $row['payment_data'], 'wcOrderId' => !empty($row['payment_wcOrderId']) ? $row['payment_wcOrderId'] : null ]; } } /** @var Collection $collection */ $collection = new Collection(); foreach ($packagesCustomersServices as $key => $value) { $collection->addItem( self::create($value), $key ); } return $collection; } } Bookable/Service/ResourceFactory.php 0000666 00000007170 15165637651 0013542 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Resource; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\EntityType; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Status; /** * Class ResourceFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class ResourceFactory { /** * @param $data * * @return Resource * @throws InvalidArgumentException */ public static function create($data) { /** @var Resource $resource */ $resource = new Resource(); if (isset($data['id'])) { $resource->setId(new Id($data['id'])); } if (isset($data['name'])) { $resource->setName(new Name($data['name'])); } if (!empty($data['quantity'])) { $resource->setQuantity(new PositiveInteger($data['quantity'])); } if (!empty($data['status'])) { $resource->setStatus(new Status($data['status'])); } if (isset($data['shared'])) { $resource->setShared(new EntityType($data['shared'])); } if (isset($data['entities'])) { $resource->setEntities(($data['entities'])); } if (!empty($data['countAdditionalPeople'])) { $resource->setCountAdditionalPeople(new BooleanValueObject($data['countAdditionalPeople'])); } return $resource; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $resources = []; foreach ($rows as $row) { $resourceId = $row['resource_id']; $resourceEntityId = $row['resource_entity_id']; $resources[$resourceId]['id'] = $row['resource_id']; $resources[$resourceId]['name'] = $row['resource_name']; $resources[$resourceId]['quantity'] = $row['resource_quantity']; $resources[$resourceId]['countAdditionalPeople'] = $row['resource_countAdditionalPeople']; $resources[$resourceId]['status'] = $row['resource_status']; $resources[$resourceId]['shared'] = $row['resource_shared']; if (!isset($resources[$resourceId]['entities'])) { $resources[$resourceId]['entities'] = []; } if ($resourceEntityId) { $resources[$resourceId]['entities'][$resourceEntityId]['id'] = (int)$resourceEntityId; $resources[$resourceId]['entities'][$resourceEntityId]['resourceId'] = (int)$resourceId; $resources[$resourceId]['entities'][$resourceEntityId]['entityId'] = (int)$row['resource_entity_entityId']; $resources[$resourceId]['entities'][$resourceEntityId]['entityType'] = $row['resource_entity_entityType']; } } $resourcesCollection = new Collection(); foreach ($resources as $key => $resourceArray) { $resourcesCollection->addItem( self::create($resourceArray), $key ); } return $resourcesCollection; } } Bookable/Service/PackageServiceFactory.php 0000666 00000005002 15165637651 0014617 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\PackageService; use AmeliaBooking\Domain\Factory\Location\LocationFactory; use AmeliaBooking\Domain\Factory\User\UserFactory; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; /** * Class PackageServiceFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class PackageServiceFactory { /** * @param $data * * @return PackageService * @throws InvalidArgumentException */ public static function create($data) { /** @var PackageService $packageService */ $packageService = new PackageService(); if (isset($data['id'])) { $packageService->setId(new Id($data['id'])); } if (isset($data['quantity'])) { $packageService->setQuantity(new PositiveInteger($data['quantity'])); } if (isset($data['service'])) { $packageService->setService(ServiceFactory::create($data['service'])); } if (isset($data['minimumScheduled'])) { $packageService->setMinimumScheduled(new WholeNumber($data['minimumScheduled'])); } if (isset($data['maximumScheduled'])) { $packageService->setMaximumScheduled(new WholeNumber($data['maximumScheduled'])); } if (isset($data['allowProviderSelection'])) { $packageService->setAllowProviderSelection(new BooleanValueObject($data['allowProviderSelection'])); } $packageService->setProviders(new Collection()); if (!empty($data['providers'])) { foreach ($data['providers'] as $providerData) { $packageService->getProviders()->addItem(UserFactory::create($providerData)); } } $packageService->setLocations(new Collection()); if (!empty($data['locations'])) { foreach ($data['locations'] as $locationData) { $packageService->getLocations()->addItem(LocationFactory::create($locationData)); } } return $packageService; } } Bookable/Service/PackageFactory.php 0000666 00000032036 15165637651 0013305 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Bookable\Service; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Bookable\Service\Package; use AmeliaBooking\Domain\Entity\Entities; use AmeliaBooking\Domain\Entity\Gallery\GalleryImage; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\DiscountPercentageValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\Number\Float\Price; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\DepositType; use AmeliaBooking\Domain\ValueObjects\String\EntityType; use AmeliaBooking\Domain\ValueObjects\String\Color; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Status; /** * Class PackageFactory * * @package AmeliaBooking\Domain\Factory\Bookable\Service */ class PackageFactory { /** * @param $data * * @return Package * @throws InvalidArgumentException */ public static function create($data) { /** @var Package $package */ $package = new Package(); if (isset($data['id'])) { $package->setId(new Id($data['id'])); } if (isset($data['name'])) { $package->setName(new Name($data['name'])); } if (isset($data['price'])) { $package->setPrice(new Price($data['price'])); } if (isset($data['description'])) { $package->setDescription(new Description($data['description'])); } if (isset($data['color'])) { $package->setColor(new Color($data['color'])); } if (!empty($data['pictureFullPath']) && !empty($data['pictureThumbPath'])) { $package->setPicture(new Picture($data['pictureFullPath'], $data['pictureThumbPath'])); } if (!empty($data['position'])) { $package->setPosition(new PositiveInteger($data['position'])); } if (!empty($data['status'])) { $package->setStatus(new Status($data['status'])); } if (isset($data['calculatedPrice'])) { $package->setCalculatedPrice(new BooleanValueObject($data['calculatedPrice'])); } if (isset($data['discount'])) { $package->setDiscount(new DiscountPercentageValue($data['discount'])); } if (!empty($data['settings'])) { $package->setSettings(new Json($data['settings'])); } if (!empty($data['endDate'])) { $package->setEndDate( new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['endDate'])) ); } if (!empty($data['durationCount'])) { $package->setDurationCount(new PositiveInteger($data['durationCount'])); } if (!empty($data['durationType'])) { $package->setDurationType(new Label($data['durationType'])); } if (isset($data['deposit'])) { $package->setDeposit(new Price($data['deposit'])); } if (isset($data['depositPayment'])) { $package->setDepositPayment(new DepositType($data['depositPayment'])); } if (isset($data['fullPayment'])) { $package->setFullPayment(new BooleanValueObject($data['fullPayment'])); } if (isset($data['limitPerCustomer'])) { $package->setLimitPerCustomer(new Json($data['limitPerCustomer'])); } /** @var Collection $gallery */ $gallery = new Collection(); if (!empty($data['gallery'])) { foreach ((array)$data['gallery'] as $image) { $galleryImage = new GalleryImage( new EntityType(Entities::PACKAGE), new Picture($image['pictureFullPath'], $image['pictureThumbPath']), new PositiveInteger($image['position']) ); if (!empty($image['id'])) { $galleryImage->setId(new Id($image['id'])); } if ($package->getId()) { $galleryImage->setEntityId($package->getId()); } $gallery->addItem($galleryImage); } } $package->setGallery($gallery); if (!empty($data['translations'])) { $package->setTranslations(new Json($data['translations'])); } if (isset($data['sharedCapacity'])) { $package->setSharedCapacity(new BooleanValueObject($data['sharedCapacity'])); } if (isset($data['quantity'])) { $package->setQuantity(new PositiveInteger($data['quantity'])); } /** @var Collection $bookable */ $bookable = new Collection(); if (!empty($data['bookable'])) { foreach ($data['bookable'] as $key => $value) { $bookable->addItem(PackageServiceFactory::create($value), $key); } } $package->setBookable($bookable); return $package; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException */ public static function createCollection($rows) { $packages = []; foreach ($rows as $row) { $packageId = $row['package_id']; $bookableId = $row['package_service_id']; $galleryId = isset($row['gallery_id']) ? $row['gallery_id'] : null; $providerId = isset($row['provider_id']) ? $row['provider_id'] : null; $locationId = isset($row['location_id']) ? $row['location_id'] : null; $packages[$packageId]['id'] = $row['package_id']; $packages[$packageId]['name'] = $row['package_name']; $packages[$packageId]['description'] = $row['package_description']; $packages[$packageId]['color'] = $row['package_color']; $packages[$packageId]['price'] = $row['package_price']; $packages[$packageId]['status'] = $row['package_status']; $packages[$packageId]['pictureFullPath'] = $row['package_picture_full']; $packages[$packageId]['pictureThumbPath'] = $row['package_picture_thumb']; $packages[$packageId]['position'] = isset($row['package_position']) ? $row['package_position'] : 0; $packages[$packageId]['calculatedPrice'] = $row['package_calculated_price']; $packages[$packageId]['sharedCapacity'] = isset($row['package_sharedCapacity']) ? $row['package_sharedCapacity'] : null; $packages[$packageId]['quantity'] = isset($row['package_quantity']) ? $row['package_quantity'] : null; $packages[$packageId]['discount'] = $row['package_discount']; $packages[$packageId]['settings'] = $row['package_settings']; $packages[$packageId]['endDate'] = $row['package_endDate']; $packages[$packageId]['durationCount'] = $row['package_durationCount']; $packages[$packageId]['durationType'] = $row['package_durationType']; $packages[$packageId]['translations'] = $row['package_translations']; $packages[$packageId]['deposit'] = isset($row['package_deposit']) ? $row['package_deposit'] : null; $packages[$packageId]['depositPayment'] = isset($row['package_depositPayment']) ? $row['package_depositPayment'] : null; $packages[$packageId]['fullPayment'] = isset($row['package_fullPayment']) ? $row['package_fullPayment'] : 0; $packages[$packageId]['limitPerCustomer'] = isset($row['package_limitPerCustomer']) ? $row['package_limitPerCustomer'] : null; if ($bookableId) { $packages[$packageId]['bookable'][$bookableId]['id'] = $bookableId; $packages[$packageId]['bookable'][$bookableId]['service']['id'] = $row['service_id']; $packages[$packageId]['bookable'][$bookableId]['service']['name'] = $row['service_name']; $packages[$packageId]['bookable'][$bookableId]['service']['description'] = !empty($row['service_description']) ? $row['service_description'] : null; $packages[$packageId]['bookable'][$bookableId]['service']['status'] = $row['service_status']; $packages[$packageId]['bookable'][$bookableId]['service']['categoryId'] = $row['service_categoryId']; $packages[$packageId]['bookable'][$bookableId]['service']['duration'] = $row['service_duration']; $packages[$packageId]['bookable'][$bookableId]['service']['timeBefore'] = $row['service_timeBefore']; $packages[$packageId]['bookable'][$bookableId]['service']['timeAfter'] = $row['service_timeAfter']; $packages[$packageId]['bookable'][$bookableId]['service']['price'] = $row['service_price']; $packages[$packageId]['bookable'][$bookableId]['service']['minCapacity'] = $row['service_minCapacity']; $packages[$packageId]['bookable'][$bookableId]['service']['maxCapacity'] = $row['service_maxCapacity']; $packages[$packageId]['bookable'][$bookableId]['service']['pictureFullPath'] = $row['service_picture_full']; $packages[$packageId]['bookable'][$bookableId]['service']['pictureThumbPath'] = $row['service_picture_thumb']; $packages[$packageId]['bookable'][$bookableId]['service']['translations'] = !empty($row['service_translations']) ? $row['service_translations'] : null; $packages[$packageId]['bookable'][$bookableId]['quantity'] = $row['package_service_quantity']; $packages[$packageId]['bookable'][$bookableId]['minimumScheduled'] = $row['package_service_minimumScheduled']; $packages[$packageId]['bookable'][$bookableId]['maximumScheduled'] = $row['package_service_maximumScheduled']; $packages[$packageId]['bookable'][$bookableId]['allowProviderSelection'] = $row['package_service_allowProviderSelection']; $packages[$packageId]['bookable'][$bookableId]['service']['show'] = !empty($row['service_show']) ? $row['service_show'] : null; } if ($galleryId) { $packages[$packageId]['gallery'][$galleryId]['id'] = $row['gallery_id']; $packages[$packageId]['gallery'][$galleryId]['pictureFullPath'] = $row['gallery_picture_full']; $packages[$packageId]['gallery'][$galleryId]['pictureThumbPath'] = $row['gallery_picture_thumb']; $packages[$packageId]['gallery'][$galleryId]['position'] = $row['gallery_position']; } if ($providerId) { $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['id'] = $row['provider_id']; $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['firstName'] = $row['provider_firstName']; $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['lastName'] = $row['provider_lastName']; $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['email'] = $row['provider_email']; $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['status'] = !empty($row['provider_status']) ? $row['provider_status'] : Status::VISIBLE; $packages[$packageId]['bookable'][$bookableId]['providers'][$providerId]['type'] = Entities::PROVIDER; } if ($locationId) { $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['id'] = $row['location_id']; $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['name'] = $row['location_name']; $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['address'] = $row['location_address']; $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['phone'] = $row['location_phone']; $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['latitude'] = $row['location_latitude']; $packages[$packageId]['bookable'][$bookableId]['locations'][$locationId]['longitude'] = $row['location_longitude']; } } $packagesCollection = new Collection(); foreach ($packages as $packageKey => $packageArray) { if (!array_key_exists('gallery', $packageArray)) { $packageArray['gallery'] = []; } $packagesCollection->addItem( self::create($packageArray), $packageKey ); } return $packagesCollection; } } Outlook/OutlookCalendarFactory.php 0000666 00000001666 15165637651 0013363 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Outlook; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Outlook\OutlookCalendar; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Label; use AmeliaBooking\Domain\ValueObjects\String\Token; /** * Class OutlookCalendarFactory * * @package AmeliaBooking\Domain\Factory\Outlook */ class OutlookCalendarFactory { /** * @param $data * * @return OutlookCalendar * @throws InvalidArgumentException */ public static function create($data) { $outlookCalendar = new OutlookCalendar( new Token($data['token']), new Label(empty($data['calendarId']) ? null : $data['calendarId']) ); if (isset($data['id'])) { $outlookCalendar->setId(new Id($data['id'])); } return $outlookCalendar; } } Gallery/GalleryImageFactory.php 0000666 00000002436 15165637651 0012576 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Gallery; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Gallery\GalleryImage; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\EntityType; /** * Class GalleryImageFactory * * @package AmeliaBooking\Domain\Factory\CustomField */ class GalleryImageFactory { /** * @param $data * * @return GalleryImage * @throws InvalidArgumentException */ public static function create($data) { $galleryImage = new GalleryImage( new EntityType($data['entityType']), new Picture($data['pictureFullPath'], $data['pictureThumbPath']), new PositiveInteger($data['position']) ); if (isset($data['id'])) { $galleryImage->setId(new Id($data['id'])); } if (isset($data['entityId'])) { $galleryImage->setEntityId(new Id($data['entityId'])); } if (isset($data['entityType'])) { $galleryImage->setEntityType(new EntityType($data['entityType'])); } return $galleryImage; } } CustomField/CustomFieldFactory.php 0000666 00000015064 15165637651 0013272 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\CustomField; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\CustomField\CustomField; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; use AmeliaBooking\Domain\Factory\Booking\Event\EventFactory; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\CustomFieldType; use AmeliaBooking\Domain\ValueObjects\String\Label; /** * Class CustomFieldFactory * * @package AmeliaBooking\Domain\Factory\CustomField */ class CustomFieldFactory { /** * @param $data * * @return CustomField * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function create($data) { $customField = new CustomField( new Label($data['label']), new CustomFieldType($data['type']), new BooleanValueObject($data['required']), new IntegerValue($data['position']) ); if (isset($data['id'])) { $customField->setId(new Id($data['id'])); } if (isset($data['options'])) { $optionList = []; /** @var array $options */ $options = $data['options']; foreach ($options as $option) { $optionList[] = CustomFieldOptionFactory::create($option); } $customField->setOptions(new Collection($optionList)); } if (isset($data['translations'])) { $customField->setTranslations(new Json($data['translations'])); } $serviceList = []; if (isset($data['allServices']) && $data['allServices']) { $customField->setAllServices(new BooleanValueObject(true)); } else { $customField->setAllServices(new BooleanValueObject(false)); if (isset($data['services'])) { /** @var array $options */ $services = $data['services']; foreach ($services as $service) { $serviceList[] = ServiceFactory::create($service); } } } $customField->setServices(new Collection($serviceList)); $eventList = []; if (isset($data['allEvents']) && $data['allEvents']) { $customField->setAllEvents(new BooleanValueObject(true)); } else { $customField->setAllEvents(new BooleanValueObject(false)); if (isset($data['events'])) { /** @var array $options */ $events = $data['events']; foreach ($events as $event) { $eventList[] = EventFactory::create($event); } } } $customField->setEvents(new Collection($eventList)); return $customField; } /** * @param array $rows * * @return Collection * @throws InvalidArgumentException * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function createCollection($rows) { $customFields = []; foreach ($rows as $row) { $customFieldId = $row['cf_id']; $optionId = $row['cfo_id']; $serviceId = $row['s_id']; $eventId = $row['e_id']; $customFields[$customFieldId]['id'] = $row['cf_id']; $customFields[$customFieldId]['label'] = $row['cf_label']; $customFields[$customFieldId]['type'] = $row['cf_type']; $customFields[$customFieldId]['required'] = $row['cf_required']; $customFields[$customFieldId]['position'] = $row['cf_position']; $customFields[$customFieldId]['translations'] = $row['cf_translations']; $customFields[$customFieldId]['allServices'] = $row['cf_allServices']; $customFields[$customFieldId]['allEvents'] = $row['cf_allEvents']; if ($optionId) { $customFields[$customFieldId]['options'][$optionId]['id'] = $row['cfo_id']; $customFields[$customFieldId]['options'][$optionId]['customFieldId'] = $row['cfo_custom_field_id']; $customFields[$customFieldId]['options'][$optionId]['label'] = $row['cfo_label']; $customFields[$customFieldId]['options'][$optionId]['position'] = $row['cfo_position']; $customFields[$customFieldId]['options'][$optionId]['translations'] = $row['cfo_translations']; } if ($serviceId) { $customFields[$customFieldId]['services'][$serviceId]['id'] = $row['s_id']; $customFields[$customFieldId]['services'][$serviceId]['name'] = $row['s_name']; $customFields[$customFieldId]['services'][$serviceId]['description'] = $row['s_description']; $customFields[$customFieldId]['services'][$serviceId]['color'] = $row['s_color']; $customFields[$customFieldId]['services'][$serviceId]['price'] = $row['s_price']; $customFields[$customFieldId]['services'][$serviceId]['status'] = $row['s_status']; $customFields[$customFieldId]['services'][$serviceId]['categoryId'] = $row['s_categoryId']; $customFields[$customFieldId]['services'][$serviceId]['minCapacity'] = $row['s_minCapacity']; $customFields[$customFieldId]['services'][$serviceId]['maxCapacity'] = $row['s_maxCapacity']; $customFields[$customFieldId]['services'][$serviceId]['duration'] = $row['s_duration']; } if ($eventId) { $customFields[$customFieldId]['events'][$eventId]['id'] = $row['e_id']; $customFields[$customFieldId]['events'][$eventId]['name'] = $row['e_name']; $customFields[$customFieldId]['events'][$eventId]['price'] = $row['e_price']; $customFields[$customFieldId]['events'][$eventId]['parentId'] = $row['e_parentId']; } } $customFieldsCollection = new Collection(); foreach ($customFields as $customFieldKey => $customFieldArray) { if (!array_key_exists('options', $customFieldArray)) { $customFieldArray['options'] = []; } $customFieldsCollection->addItem( self::create($customFieldArray), $customFieldKey ); } return $customFieldsCollection; } } CustomField/CustomFieldOptionFactory.php 0000666 00000002243 15165637651 0014456 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\CustomField; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\CustomField\CustomFieldOption; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue; use AmeliaBooking\Domain\ValueObjects\String\Label; /** * Class CustomFieldOptionFactory * * @package AmeliaBooking\Domain\Factory\CustomField */ class CustomFieldOptionFactory { /** * @param $data * * @return CustomFieldOption * @throws InvalidArgumentException */ public static function create($data) { $customFieldOption = new CustomFieldOption( new Id($data['customFieldId']), new Label($data['label']), new IntegerValue($data['position']) ); if (isset($data['translations'])) { $customFieldOption->setTranslations(new Json($data['translations'])); } if (isset($data['id'])) { $customFieldOption->setId(new Id($data['id'])); } return $customFieldOption; } } Coupon/CouponFactory.php 0000666 00000016277 15165637651 0011353 0 ustar 00 <?php /** * @copyright © TMS-Plugins. All rights reserved. * @licence See LICENCE.md for license details. */ namespace AmeliaBooking\Domain\Factory\Coupon; use AmeliaBooking\Domain\Collection\Collection; use AmeliaBooking\Domain\Entity\Coupon\Coupon; use AmeliaBooking\Domain\Factory\Bookable\Service\ServiceFactory; use AmeliaBooking\Domain\Factory\Booking\Event\EventFactory; use AmeliaBooking\Domain\Factory\Bookable\Service\PackageFactory; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\DiscountFixedValue; use AmeliaBooking\Domain\ValueObjects\DiscountPercentageValue; use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; use AmeliaBooking\Domain\ValueObjects\Number\Integer\WholeNumber; use AmeliaBooking\Domain\ValueObjects\String\CouponCode; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class CouponFactory * * @package AmeliaBooking\Domain\Factory\Coupon */ class CouponFactory { /** * @param $data * * @return Coupon * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function create($data) { $coupon = new Coupon( new CouponCode($data['code']), new DiscountPercentageValue($data['discount']), new DiscountFixedValue($data['deduction']), new PositiveInteger((int)$data['limit']), new Status($data['status']) ); if (isset($data['id'])) { $coupon->setId(new Id($data['id'])); } $serviceList = new Collection(); if (isset($data['serviceList'])) { foreach ((array)$data['serviceList'] as $key => $value) { $serviceList->addItem( ServiceFactory::create($value), $key ); } } $eventList = new Collection(); if (isset($data['eventList'])) { foreach ((array)$data['eventList'] as $key => $value) { $eventList->addItem( EventFactory::create($value), $key ); } } $packageList = new Collection(); if (isset($data['packageList'])) { foreach ((array)$data['packageList'] as $key => $value) { $packageList->addItem( PackageFactory::create($value), $key ); } } if (isset($data['customerLimit'])) { $coupon->setCustomerLimit(new WholeNumber((int)$data['customerLimit'])); } if (isset($data['notificationInterval'])) { $coupon->setNotificationInterval(new WholeNumber($data['notificationInterval'])); } if (isset($data['notificationRecurring'])) { $coupon->setNotificationRecurring(new BooleanValueObject($data['notificationRecurring'])); } if (isset($data['used'])) { $coupon->setUsed(new WholeNumber($data['used'])); } if (!empty($data['expirationDate'])) { if (is_string($data['expirationDate'])) { $coupon->setExpirationDate(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['expirationDate']))); } else { $coupon->setExpirationDate(new DateTimeValue($data['expirationDate'])); } } $coupon->setServiceList($serviceList); $coupon->setEventList($eventList); $coupon->setPackageList($packageList); return $coupon; } /** * @param array $rows * * @return Collection * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException */ public static function createCollection($rows) { $coupons = []; foreach ($rows as $row) { $couponId = $row['coupon_id']; $serviceId = isset($row['service_id']) ? $row['service_id'] : null; $eventId = isset($row['event_id']) ? $row['event_id'] : null; $packageId = isset($row['package_id']) ? $row['package_id'] : null; $bookingId = isset($row['booking_id']) ? $row['booking_id'] : null; $coupons[$couponId]['id'] = $couponId; $coupons[$couponId]['code'] = $row['coupon_code']; $coupons[$couponId]['discount'] = $row['coupon_discount']; $coupons[$couponId]['deduction'] = $row['coupon_deduction']; $coupons[$couponId]['limit'] = $row['coupon_limit']; $coupons[$couponId]['customerLimit'] = $row['coupon_customerLimit']; $coupons[$couponId]['notificationInterval'] = $row['coupon_notificationInterval']; $coupons[$couponId]['notificationRecurring'] = $row['coupon_notificationRecurring']; $coupons[$couponId]['status'] = $row['coupon_status']; $coupons[$couponId]['expirationDate'] = $row['coupon_expirationDate']; if ($bookingId) { $coupons[$couponId]['bookings'][$bookingId] = $bookingId; } if ($serviceId) { $coupons[$couponId]['serviceList'][$serviceId]['id'] = $serviceId; $coupons[$couponId]['serviceList'][$serviceId]['name'] = $row['service_name']; $coupons[$couponId]['serviceList'][$serviceId]['description'] = $row['service_description']; $coupons[$couponId]['serviceList'][$serviceId]['color'] = $row['service_color']; $coupons[$couponId]['serviceList'][$serviceId]['status'] = $row['service_status']; $coupons[$couponId]['serviceList'][$serviceId]['categoryId'] = $row['service_categoryId']; $coupons[$couponId]['serviceList'][$serviceId]['duration'] = $row['service_duration']; $coupons[$couponId]['serviceList'][$serviceId]['price'] = $row['service_price']; $coupons[$couponId]['serviceList'][$serviceId]['minCapacity'] = $row['service_minCapacity']; $coupons[$couponId]['serviceList'][$serviceId]['maxCapacity'] = $row['service_maxCapacity']; } if ($eventId) { $coupons[$couponId]['eventList'][$eventId]['id'] = $eventId; $coupons[$couponId]['eventList'][$eventId]['name'] = $row['event_name']; $coupons[$couponId]['eventList'][$eventId]['price'] = $row['event_price']; } if ($packageId) { $coupons[$couponId]['packageList'][$packageId]['id'] = $packageId; $coupons[$couponId]['packageList'][$packageId]['name'] = $row['package_name']; $coupons[$couponId]['packageList'][$packageId]['price'] = $row['package_price']; } } $couponsCollection = new Collection(); foreach ($coupons as $couponKey => $couponArray) { $couponArray['used'] = isset($couponArray['bookings']) ? sizeof($couponArray['bookings']) : 0; $couponsCollection->addItem( self::create($couponArray), $couponKey ); } return $couponsCollection; } } Location/LocationFactory.php 0000666 00000004351 15165637651 0012153 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Location; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Location\Location; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\String\Status; use AmeliaBooking\Domain\ValueObjects\Picture; use AmeliaBooking\Domain\ValueObjects\String\Address; use AmeliaBooking\Domain\ValueObjects\String\Description; use AmeliaBooking\Domain\ValueObjects\GeoTag; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\Phone; use AmeliaBooking\Domain\ValueObjects\String\Url; /** * Class LocationFactory * * @package AmeliaBooking\Domain\Factory\Location */ class LocationFactory { /** * @param $data * * @return Location * @throws InvalidArgumentException */ public static function create($data) { $location = new Location(); if (isset($data['id'])) { $location->setId(new Id($data['id'])); } if (isset($data['name'])) { $location->setName(new Name($data['name'])); } if (isset($data['address'])) { $location->setAddress(new Address($data['address'])); } if (isset($data['phone'])) { $location->setPhone(new Phone($data['phone'])); } if (isset($data['latitude'], $data['longitude'])) { $location->setCoordinates(new GeoTag($data['latitude'], $data['longitude'])); } if (isset($data['description'])) { $location->setDescription(new Description($data['description'])); } if (isset($data['status'])) { $location->setStatus(new Status($data['status'])); } if (!empty($data['pictureFullPath']) && !empty($data['pictureThumbPath'])) { $location->setPicture(new Picture($data['pictureFullPath'], $data['pictureThumbPath'])); } if (isset($data['pin'])) { $location->setPin(new Url($data['pin'])); } if (!empty($data['translations'])) { $location->setTranslations(new Json($data['translations'])); } return $location; } } Location/ProviderLocationFactory.php 0000666 00000001304 15165637651 0013661 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Location; use AmeliaBooking\Domain\Entity\Location\ProviderLocation; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; /** * Class ProviderLocationFactory * * @package AmeliaBooking\Domain\Factory\Location */ class ProviderLocationFactory { /** * @param $data * * @return ProviderLocation */ public static function create($data) { $providerLocation = new ProviderLocation( new Id($data['userId']), new Id($data['locationId']) ); if (isset($data['id'])) { $providerLocation->setId(new Id($data['id'])); } return $providerLocation; } } Notification/NotificationFactory.php 0000666 00000005160 15165637651 0013706 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Notification; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Notification\Notification; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\TimeOfDay; use AmeliaBooking\Domain\ValueObjects\Duration; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\BookingType; use AmeliaBooking\Domain\ValueObjects\String\Html; use AmeliaBooking\Domain\ValueObjects\String\Name; use AmeliaBooking\Domain\ValueObjects\String\NotificationSendTo; use AmeliaBooking\Domain\ValueObjects\String\NotificationStatus; use AmeliaBooking\Domain\ValueObjects\String\NotificationType; /** * Class NotificationFactory * * @package AmeliaBooking\Domain\Factory\Notification */ class NotificationFactory { /** * @param array $data * * @return Notification * @throws InvalidArgumentException */ public static function create($data) { $notification = new Notification( new Name($data['name']), new NotificationStatus($data['status']), new NotificationType($data['type']), new BookingType($data['entity']), new NotificationSendTo($data['sendTo']), new Name($data['subject']), new Html($data['content']) ); if (isset($data['id'])) { $notification->setId(new Id($data['id'])); } if (isset($data['customName']) && !empty($data['customName'])) { $notification->setCustomName($data['customName']); } if (isset($data['time'])) { $notification->setTime(new TimeOfDay($data['time'])); } if (isset($data['timeBefore'])) { $notification->setTimeBefore(new Duration($data['timeBefore'])); } if (isset($data['translations'])) { $notification->setTranslations(new Json($data['translations'])); } if (isset($data['timeAfter'])) { $notification->setTimeAfter(new Duration($data['timeAfter'])); } if (isset($data['entityIds'])) { $notification->setEntityIds(($data['entityIds'])); } if (isset($data['sendOnlyMe']) && !empty($data['sendOnlyMe'])) { $notification->setSendOnlyMe(new BooleanValueObject($data['sendOnlyMe'])); } if (isset($data['whatsAppTemplate'])) { $notification->setWhatsAppTemplate($data['whatsAppTemplate']); } return $notification; } } Notification/NotificationLogFactory.php 0000666 00000004156 15165637651 0014354 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Notification; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Notification\NotificationLog; use AmeliaBooking\Domain\Services\DateTime\DateTimeService; use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; use AmeliaBooking\Domain\ValueObjects\Json; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use Exception; /** * Class NotificationLogFactory * * @package AmeliaBooking\Domain\Factory\Notification */ class NotificationLogFactory { /** * @param array $data * * @return NotificationLog * @throws InvalidArgumentException * @throws Exception */ public static function create($data) { $notificationLog = new NotificationLog(); if (isset($data['id'])) { $notificationLog->setId(new Id($data['id'])); } if (isset($data['notificationId'])) { $notificationLog->setNotificationsId(new Id($data['notificationId'])); } if (isset($data['userId'])) { $notificationLog->setUserId(new Id($data['userId'])); } if (isset($data['appointmentId'])) { $notificationLog->setAppointmentId(new Id($data['appointmentId'])); } if (isset($data['eventId'])) { $notificationLog->setEventId(new Id($data['eventId'])); } if (isset($data['packageCustomerId'])) { $notificationLog->setPackageCustomerId(new Id($data['packageCustomerId'])); } if (isset($data['sentDateTime'])) { $notificationLog->setSentDateTime( new DateTimeValue( DateTimeService::getCustomDateTimeObjectFromUtc($data['sentDateTime']) ) ); } if (isset($data['sent'])) { $notificationLog->setSent(new BooleanValueObject($data['sent'])); } if (isset($data['data'])) { $notificationLog->setData(new Json($data['data'])); } return $notificationLog; } } Zoom/ZoomFactory.php 0000666 00000001663 15165637651 0010506 0 ustar 00 <?php namespace AmeliaBooking\Domain\Factory\Zoom; use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; use AmeliaBooking\Domain\Entity\Zoom\ZoomMeeting; use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; use AmeliaBooking\Domain\ValueObjects\String\Url; /** * Class ZoomFactory * * @package AmeliaBooking\Domain\Factory\Zoom */ class ZoomFactory { /** * @param $data * * @return ZoomMeeting * @throws InvalidArgumentException */ public static function create($data) { $zoomMeeting = new ZoomMeeting(); if (isset($data['id'])) { $zoomMeeting->setId(new Id($data['id'])); } if (isset($data['joinUrl'])) { $zoomMeeting->setJoinUrl(new Url($data['joinUrl'])); } if (isset($data['startUrl'])) { $zoomMeeting->setStartUrl(new Url($data['startUrl'])); } return $zoomMeeting; } }
| ver. 1.4 |
Github
|
.
| PHP 5.4.45 | Generation time: 0 |
proxy
|
phpinfo
|
Settings