diff --git a/Block/System/Config/Form/Field/Version.php b/Block/System/Config/Form/Field/Version.php index 469ffe1026a318d35fe1594ee5d530beb0be3a37..964f53cfe5cfdc52a4de73baf68d88fe3cb38f1c 100644 --- a/Block/System/Config/Form/Field/Version.php +++ b/Block/System/Config/Form/Field/Version.php @@ -1,11 +1,12 @@ <?php -namespace uafrica\Customshipping\Block\System\Config\Form\Field; +namespace bobgo\CustomShipping\Block\System\Config\Form\Field; use Magento\Framework\Data\Form\Element\AbstractElement; /** + * Displays Version number in System Configuration * @category BobGroup - * @package uafrica_customshipping + * @package bobgo_CustomShipping * @author info@bob.co.za * @website https://www.bob.co.za */ @@ -14,17 +15,17 @@ class Version extends \Magento\Config\Block\System\Config\Form\Field const EXTENSION_URL = 'https://www.bob.co.za'; /** - * @var \uafrica\Customshipping\Helper\Data $helper + * @var \bobgo\CustomShipping\Helper\Data $helper */ protected $_helper; /** * @param \Magento\Backend\Block\Template\Context $context - * @param \uafrica\Customshipping\Helper\Data $helper + * @param \bobgo\CustomShipping\Helper\Data $helper */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \uafrica\Customshipping\Helper\Data $helper + \bobgo\CustomShipping\Helper\Data $helper ) { $this->_helper = $helper; parent::__construct($context); diff --git a/Helper/Data.php b/Helper/Data.php index edaa3a3c4130e14603ee05b0257faaf613d02bb6..f1da9bdf1359370d934f38be1c520e0ac1786a00 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -1,5 +1,5 @@ <?php -namespace uafrica\Customshipping\Helper; +namespace bobgo\CustomShipping\Helper; use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\Context; @@ -7,16 +7,16 @@ use Magento\Framework\Module\ModuleListInterface; use Magento\Store\Model\ScopeInterface; /** - * @category uafrica - * @package uafrica_customshipping - * @author uafrica + * @category bobgo + * @package bobgo_CustomShipping + * @author bobgo * @website https://www.bob.co.za */ class Data extends AbstractHelper { - const XML_PATH_ENABLED = 'uafrica_customshipping/general/enabled'; - const XML_PATH_DEBUG = 'uafrica_customshipping/general/debug'; + const XML_PATH_ENABLED = 'bobgo_CustomShipping/general/enabled'; + const XML_PATH_DEBUG = 'bobgo_CustomShipping/general/debug'; /** * @var \Psr\Log\LoggerInterface @@ -65,7 +65,7 @@ class Data extends AbstractHelper public function getExtensionVersion() { - $moduleCode = 'uafrica_Customshipping'; + $moduleCode = 'bobgo_CustomShipping'; $moduleInfo = $this->_moduleList->getOne($moduleCode); return $moduleInfo['setup_version']; } diff --git a/Model/Carrier/Company.php b/Model/Carrier/Company.php index 4b6415834aa2d67b045fa7bff94f5ba3ca970e34..c0d6a932df2aa37fdcaef03a53b0cceea8adb38d 100644 --- a/Model/Carrier/Company.php +++ b/Model/Carrier/Company.php @@ -1,7 +1,10 @@ <?php -namespace uafrica\Customshipping\Model\Carrier; +namespace bobgo\CustomShipping\Model\Carrier; +/** + * Get the Company information from the request body and return it + */ class Company { diff --git a/Model/Carrier/Customshipping.php b/Model/Carrier/CustomShipping.php similarity index 87% rename from Model/Carrier/Customshipping.php rename to Model/Carrier/CustomShipping.php index f1c86eb1489d124154d812da7dcef3807f57b0a8..d007495e2705e5f221a2c1077978d51f981617c5 100644 --- a/Model/Carrier/Customshipping.php +++ b/Model/Carrier/CustomShipping.php @@ -1,7 +1,7 @@ <?php declare(strict_types=1); -namespace uafrica\Customshipping\Model\Carrier; +namespace bobgo\CustomShipping\Model\Carrier; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; use Magento\CatalogInventory\Api\StockRegistryInterface; @@ -22,6 +22,7 @@ use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory; use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory; use Magento\Shipping\Model\Carrier\AbstractCarrier; use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; +use Magento\Shipping\Model\Carrier\CarrierInterface; use Magento\Shipping\Model\Rate\Result; use Magento\Shipping\Model\Rate\ResultFactory; use Magento\Shipping\Model\Simplexml\ElementFactory; @@ -31,22 +32,23 @@ use Magento\Store\Model\StoreManagerInterface; use Psr\Log\LoggerInterface; /** - * uAfrica shipping implementation + * bobgo shipping implementation * @category bob - * @package uafrica_Customshipping + * @package bobgo_CustomShipping * @author info@bob.co.za * @website https://www.bob.co.za * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\Model\Carrier\CarrierInterface +class CustomShipping extends AbstractCarrierOnline implements CarrierInterface { /** * Code of the carrier + *` * @var string */ - public const CODE = 'uafrica'; + public const CODE = 'bobgo'; const UNITS = 100; @@ -72,12 +74,6 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ */ protected $_result = null; - /** - * Container types that could be customized for uAfrica carrier - * - * @var string[] - */ - protected $_customizableContainerTypes = ['YOUR_PACKAGING']; /** * @var \Magento\Store\Model\StoreManagerInterface @@ -184,8 +180,9 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } - /** - * Store Base Url + /* + * Gets the base url of the store by stripping the http:// or https:// and wwww. from the url + * leaving just "example.com" since bobgo API uses this format and not the full url as the Identifier * @var \Magento\Store\Model\StoreManagerInterface $this->_storeManager * @return string */ @@ -198,35 +195,36 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ return $storeBase; } - /** - * Make request to uAfrica API to get shipping rates + * Make request to bobgo API to get shipping rates for the cart + * After all the required data is collected, it makes a request to the bobgo API to get the shipping rates * @param $payload * @return array */ public function getRates($payload): array { - $response = $this->uRates($payload); - - return $response; + return $this->uRates($payload); } /** - * Collect and get rates - * + * Collect and get rates for this shipping method based on information in $request + * This is a default function that is called by Magento to get the shipping rates for the cart * @param RateRequest $request * @return Result|bool|null */ - public function collectRates(RateRequest $request) + public function collectRates(RateRequest $request): Result|bool|null { /*** Make sure that Shipping method is enabled*/ if (!$this->isActive()) { return false; } - + /** + * Gets the destination company name from Company Name field in the checkout page + * This method is used is the last resort to get the company name since the company name is not available in _rateFactory + */ $destComp = $this->getDestComp(); - /** @var \Magento\Shipping\Model\Rate\Result $result */ + /** @var Result $result */ $result = $this->_rateFactory->create(); @@ -236,13 +234,12 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ $destCity = $request->getDestCity(); $destStreet = $request->getDestStreet(); + /** Destination Information */ list($destStreet1, $destStreet2, $destStreet3) = $this->destStreet($destStreet); - - /** Origin Information */ list($originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier, $originSuburb) = $this->storeInformation(); - + /** Get all the items in the cart */ $items = $request->getAllItems(); $itemsArray = []; @@ -290,6 +287,10 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** + * Get The store information from the Magento store configuration and return it as an array + * In magento 2 there is origin information in the store information section of the configuration, so we get it from there + * since Store Information has the origin information including suburb field that we Injected upon Bob Go Extension installation + * which is not available in the origin section * @return array */ public function storeInformation(): array @@ -334,16 +335,16 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ ); $baseIdentifier = $this->getBaseUrl(); + return array($originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier, $originSuburb); } - /** * Get result of request * * @return Result|null */ - public function getResult() + public function getResult(): ?Result { if (!$this->_result) { $this->_result = $this->_trackFactory->create(); @@ -351,7 +352,6 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ return $this->_result; } - /** * Get final price for shipping method with handling fee per package * @@ -360,7 +360,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ * @param float $handlingFee * @return float */ - protected function _getPerpackagePrice($cost, $handlingType, $handlingFee) + protected function _getPerpackagePrice($cost, $handlingType, $handlingFee): float { if ($handlingType == AbstractCarrier::HANDLING_TYPE_PERCENT) { return $cost + $cost * $this->_numBoxes * $handlingFee / self::UNITS; @@ -377,7 +377,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ * @param float $handlingFee * @return float */ - protected function _getPerorderPrice($cost, $handlingType, $handlingFee) + protected function _getPerorderPrice($cost, $handlingType, $handlingFee): float { if ($handlingType == self::HANDLING_TYPE_PERCENT) { return $cost + $cost * $handlingFee / self::UNITS; @@ -386,7 +386,6 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ return $cost + $handlingFee; } - /** * Get configuration data of carrier * @@ -395,11 +394,11 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ * @return array|false * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function getCode($type, $code = '') + public function getCode($type, $code = ''): bool|array { $codes = [ 'method' => [ - 'UAFRICA_SHIPPING' => __('uAfrica Shipping'), + 'bobGo' => __('Bob Go'), ], 'delivery_confirmation_types' => [ 'NO_SIGNATURE_REQUIRED' => __('Not Required'), @@ -425,14 +424,14 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } } - /** - * Get tracking + * Get tracking info by tracking number or tracking request + * Without getTrackingInfo() method, Magento will not show tracking info on frontend * * @param string|string[] $trackings * @return Result|null */ - public function getTracking($trackings) + public function getTracking($trackings): ?Result { $this->setTrackingReqeust(); @@ -448,11 +447,11 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** - * Set tracking request + * Set tracking request data for request by getting context from Magento * * @return void */ - protected function setTrackingReqeust() + protected function setTrackingReqeust(): void { $r = new \Magento\Framework\DataObject(); @@ -463,23 +462,23 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** - * Send request for tracking + * Send request for the actual tracking info and process response * * @param string[] $tracking * @return void */ - protected function _getXMLTracking($tracking) + protected function _getXMLTracking($tracking): void { $this->_parseTrackingResponse($tracking); } /** - * Parse tracking response + * Parse tracking response and set tracking info * * @param string $trackingValue * @return void */ - protected function _parseTrackingResponse($trackingValue) + protected function _parseTrackingResponse($trackingValue): void { $result = $this->getResult(); $carrierTitle = $this->getConfigData('title'); @@ -513,7 +512,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ * * @return string */ - public function getResponse() + public function getResponse(): string { $statuses = ''; if ($this->_result instanceof \Magento\Shipping\Model\Tracking\Result) { @@ -542,7 +541,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ * * @return array */ - public function getAllowedMethods() + public function getAllowedMethods(): array { $allowed = explode(',', $this->getConfigData('allowed_methods')); $arr = []; @@ -553,14 +552,13 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ return $arr; } - /** * Do shipment request to carrier web service, obtain Print Shipping Labels and process errors in response - * + * Also another magic function that is required to be implemented by carrier model * @param \Magento\Framework\DataObject $request * @return \Magento\Framework\DataObject */ - protected function _doShipmentRequest(\Magento\Framework\DataObject $request) + protected function _doShipmentRequest(\Magento\Framework\DataObject $request): ?DataObject { return null; @@ -573,7 +571,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ * * @return bool */ - public function rollBack($data) + public function rollBack($data): bool { return true; } @@ -586,7 +584,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ * @return array|bool * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function getContainerTypes(\Magento\Framework\DataObject $params = null) + public function getContainerTypes(\Magento\Framework\DataObject $params = null): bool|array { $result = []; $allowedContainers = $this->getConfigData('containers'); @@ -634,7 +632,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** - * Parse track details response from uAfrica + * Parse track details response from bobgo * * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) @@ -700,7 +698,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** - * Perfom API Request to uAfrica API and return response + * Perform API Request to bobgo API and return response * @param array $payload * @param Result $result * @return void @@ -715,14 +713,14 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** - * Perform API Request for Shipment Tracking to uAfrica API and return response + * Perform API Request for Shipment Tracking to bobgo API and return response * @param $trackInfo * @param array $result * @return array */ private function _requestTracking($trackInfo, array $result): array { - $response = $this->trackUafricaShipment($trackInfo); + $response = $this->trackBobgoShipment($trackInfo); $result = $this->prepareActivity($response[0], $result); @@ -730,7 +728,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } /** - * Format rates from uAfrica API response and append to rate result instance of carrier + * Format rates from bobgo API response and append to rate result instance of carrier * @param mixed $rates * @param Result $result * @return void @@ -773,9 +771,8 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } } - /** - * Prepare received checkpoints and activity from uAfrica Shipment Tracking API + * Prepare received checkpoints and activity from bobgo Shipment Tracking API * @param $response * @param array $result * @return array @@ -788,7 +785,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ 'activity' => $checkpoint['status'], 'deliverydate' => $this->formatDate($checkpoint['time']), 'deliverytime' => $this->formatTime($checkpoint['time']), - //'deliverylocation' => 'Unavailable', + // 'deliverylocation' => 'Unavailable',//TODO: remove this line ]; } return $result; @@ -822,23 +819,22 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ } } - /** - * Curl request to uAfrica Shipment Tracking API + * Curl request to bobgo Shipment Tracking API * @param $trackInfo * @return mixed */ - private function trackUafricaShipment($trackInfo): mixed + private function trackBobgoShipment($trackInfo): mixed { $this->curl->get(uData::TRACKING . $trackInfo); $response = $this->curl->getBody(); - $response = json_decode($response, true); - return $response; + return json_decode($response, true); } /** + * Build The Payload for bobgo API Request and return response * @param array $payload * @return mixed */ @@ -853,7 +849,6 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ return $rates; } - /** * @param string $destStreet * @return string[] diff --git a/Model/Carrier/uData.php b/Model/Carrier/uData.php index b293e7fd166444f63a8a91413442806e66e6d449..476e9a1f4c22960f2de0a9fada874143a2c49863 100644 --- a/Model/Carrier/uData.php +++ b/Model/Carrier/uData.php @@ -1,16 +1,16 @@ <?php -namespace uafrica\Customshipping\Model\Carrier; +namespace bobgo\CustomShipping\Model\Carrier; /** * Class uData - * @package uafrica\Customshipping\Model\Carrier + * bobGo API Resources for Custom Shipping + * @package bobgo\CustomShipping\Model\Carrier */ class uData { - /** Tracking Endpoint */ public const TRACKING = 'https://api.dev.ship.uafrica.com/tracking?channel=localhost&tracking_reference='; /*** RATES API Endpoint*/ - public const RATES_ENDPOINT = 'https://api.dev.ship.uafrica.com/rates-at-checkout/woocommerce'; + public const RATES_ENDPOINT = 'https://api.dev.ship.uafrica.com/rates-at-checkout/magento'; } diff --git a/Model/Carrier/uSub.php b/Model/Carrier/uSub.php index 38040f0eb259f015ba1c4ae46523f69fc738070e..96ae4747c1b928eefd2843b4d711fdc468c4e9bc 100644 --- a/Model/Carrier/uSub.php +++ b/Model/Carrier/uSub.php @@ -1,6 +1,6 @@ <?php -namespace uafrica\Customshipping\Model\Carrier; +namespace bobgo\CustomShipping\Model\Carrier; use Magento\Checkout\Api\Data\ShippingInformationInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\NoSuchEntityException; @@ -11,6 +11,8 @@ class uSub { /** + * This is supposed to get the suburb from the shipping address extension attributes. + * Does not work for now, was supposed to access the suburb attribute from the shipping address extension attributes. * @throws NoSuchEntityException */ public function getDestSuburb() diff --git a/Model/Source/Dropoff.php b/Model/Source/Dropoff.php index 4606fed88affd3ce7c561b626d2b0aeff10c61ff..e2705573bef8e747fc4a8759cbeb78165e5f743a 100644 --- a/Model/Source/Dropoff.php +++ b/Model/Source/Dropoff.php @@ -1,6 +1,6 @@ <?php -namespace uafrica\Customshipping\Model\Source; +namespace bobgo\CustomShipping\Model\Source; class Dropoff extends Generic { diff --git a/Model/Source/Freemethod.php b/Model/Source/Freemethod.php index d71e97c9ff1d4bb8d950c69b53c8b2812536c4ff..2ea09d3a96a72e394c04c4e72190481cdd8fd4b6 100644 --- a/Model/Source/Freemethod.php +++ b/Model/Source/Freemethod.php @@ -1,9 +1,9 @@ <?php -namespace uafrica\Customshipping\Model\Source; +namespace bobgo\CustomShipping\Model\Source; /** - * uafrica Free Method source implementation + * bobgo Free Method source implementation */ class Freemethod extends Method { diff --git a/Model/Source/Generic.php b/Model/Source/Generic.php index 0ad8d4768d8538fdc14a91c98faaa248c9a1fd01..214e8eb4d02e8d6f437d37244172ffd589362ee9 100644 --- a/Model/Source/Generic.php +++ b/Model/Source/Generic.php @@ -1,20 +1,20 @@ <?php -namespace uafrica\customshipping\Model\Source; +namespace bobgo\CustomShipping\Model\Source; use Magento\Framework\Data\OptionSourceInterface; -use uafrica\Customshipping\Model\Carrier\Customshipping; +use bobgo\CustomShipping\Model\Carrier\CustomShipping; /** - * uAfrica generic source implementation + * bobgo generic source implementation */ class Generic implements OptionSourceInterface { /** - * @var Customshipping + * @var CustomShipping */ - protected Customshipping $_shippingCustomshipping; + protected CustomShipping $_shippingCustomShipping; /** * Carrier code @@ -23,11 +23,11 @@ class Generic implements OptionSourceInterface protected string $_code = ''; /** - * @param Customshipping $shippingCustomshipping + * @param CustomShipping $shippingCustomShipping */ - public function __construct(Customshipping $shippingCustomshipping) + public function __construct(CustomShipping $shippingCustomShipping) { - $this->_shippingCustomshipping = $shippingCustomshipping; + $this->_shippingCustomShipping = $shippingCustomShipping; } /** @@ -36,7 +36,7 @@ class Generic implements OptionSourceInterface */ public function toOptionArray() { - $configData = $this->_shippingCustomshipping->getCode($this->_code); + $configData = $this->_shippingCustomShipping->getCode($this->_code); $arr = []; if ($configData) { $arr = array_map( diff --git a/Model/Source/Method.php b/Model/Source/Method.php index 0c958e50750ed8d7faa332cc1903c4e13efae178..6ff23503c0c8b273df38b0abfbc5dcee3b1e4f79 100644 --- a/Model/Source/Method.php +++ b/Model/Source/Method.php @@ -1,6 +1,6 @@ <?php -namespace uafrica\Customshipping\Model\Source; +namespace bobgo\CustomShipping\Model\Source; class Method extends Generic { diff --git a/Model/Source/Packaging.php b/Model/Source/Packaging.php index 969d080a3337621d3a7d61c091cc1f768fa093e4..5c93ad376f2c01564da7593149e89cc783dcc06f 100644 --- a/Model/Source/Packaging.php +++ b/Model/Source/Packaging.php @@ -1,6 +1,6 @@ <?php -namespace uafrica\Customshipping\Model\Source; +namespace bobgo\CustomShipping\Model\Source; class Packaging extends Generic { diff --git a/Model/Source/Unitofmeasure.php b/Model/Source/Unitofmeasure.php index 2fd77f1979280e1e25181eaf9d8446672ee353de..8ef12cdb8b4a84d1ae7a59b5c8a366a1e6d54e69 100644 --- a/Model/Source/Unitofmeasure.php +++ b/Model/Source/Unitofmeasure.php @@ -1,6 +1,6 @@ <?php -namespace uafrica\Customshipping\Model\Source; +namespace bobgo\CustomShipping\Model\Source; class Unitofmeasure extends Generic { diff --git a/Observer/SaveOrderBeforeSalesModelQuote.php b/Observer/SaveOrderBeforeSalesModelQuote.php index 1c81b724936d828e66598284be87b2da6a05db77..25cc18a5477f0a750453cda6716d5ff348e898a8 100644 --- a/Observer/SaveOrderBeforeSalesModelQuote.php +++ b/Observer/SaveOrderBeforeSalesModelQuote.php @@ -1,6 +1,6 @@ <?php -namespace uafrica\Customshipping\Observer; +namespace bobgo\CustomShipping\Observer; use Magento\Framework\DataObject\Copy; use Magento\Framework\Event\Observer; @@ -8,6 +8,11 @@ use Magento\Framework\Event\ObserverInterface; use Magento\Quote\Model\Quote; use Magento\Sales\Model\Order; +/** + * Class SaveOrderBeforeSalesModelQuote + * @package bobgo\CustomShipping\Observer + * This class is supposed to copy the suburb attribute from the quote to the order object. + */ class SaveOrderBeforeSalesModelQuote implements ObserverInterface { public Copy $objectCopyService; diff --git a/Plugin/Block/DataProviders/Tracking/ChangeTitle.php b/Plugin/Block/DataProviders/Tracking/ChangeTitle.php index 854d22746bbd8f28e33d27357d47098d9e741610..05d108bb12603f8182fcb9a0d72bc40b749fc1b9 100644 --- a/Plugin/Block/DataProviders/Tracking/ChangeTitle.php +++ b/Plugin/Block/DataProviders/Tracking/ChangeTitle.php @@ -1,20 +1,20 @@ <?php -namespace uafrica\Customshipping\Plugin\Block\DataProviders\Tracking; +namespace bobgo\CustomShipping\Plugin\Block\DataProviders\Tracking; -use uafrica\Customshipping\Model\Carrier; +use bobgo\CustomShipping\Model\Carrier; use Magento\Shipping\Model\Tracking\Result\Status; use Magento\Shipping\Block\DataProviders\Tracking\DeliveryDateTitle as Subject; /** - * Plugin to change delivery date title with UAfrica customized value + * Plugin to change delivery date title with bobgo customized value */ class ChangeTitle { /** - * Title modification in case if UAfrica used as carrier + * Title modification in case if bobgo used as carrier * * @param Subject $subject * @param \Magento\Framework\Phrase|string $result diff --git a/Plugin/Block/Tracking/PopUpDeliveryDate.php b/Plugin/Block/Tracking/PopUpDeliveryDate.php index e605536ec491c0166eca7cd90758868ceecb50f4..420d39b205ff333f48cd92c0bdfd11cb052f9516 100644 --- a/Plugin/Block/Tracking/PopUpDeliveryDate.php +++ b/Plugin/Block/Tracking/PopUpDeliveryDate.php @@ -1,18 +1,18 @@ <?php -namespace uafrica\Customshipping\Plugin\Block\Tracking; +namespace bobgo\CustomShipping\Plugin\Block\Tracking; use Magento\Shipping\Block\Tracking\Popup; use Magento\Shipping\Model\Tracking\Result\Status; use Magento\Shiiping\Model\Carrier; /* - * Plugin to update delivery date value in case if UAfrica is a carrier used + * Plugin to update delivery date value in case if bobgo is a carrier used */ class PopupDeliveryDate { /** - * Show only date for expected delivery in case if UAfrica is a carrier + * Show only date for expected delivery in case if bobgo is a carrier * * @param Popup $subject * @param string $result @@ -40,8 +40,7 @@ class PopupDeliveryDate foreach ($subject->getTrackingInfo() as $trackingData) { foreach ($trackingData as $trackingInfo) { if ($trackingInfo instanceof Status) { - $carrier = $trackingInfo->getCarrier(); - return $carrier; + return $trackingInfo->getCarrier(); } } } diff --git a/Plugin/Checkout/Block/LayoutProcessorPlugin.php b/Plugin/Checkout/Block/LayoutProcessorPlugin.php index d379412da7cfd5c94e1d03968688cd2afe30a592..6eb562667b50c5df05d1d4a05ef5337f4b29387c 100644 --- a/Plugin/Checkout/Block/LayoutProcessorPlugin.php +++ b/Plugin/Checkout/Block/LayoutProcessorPlugin.php @@ -1,51 +1,82 @@ <?php -namespace uafrica\Customshipping\Plugin\Checkout\Block; +namespace bobgo\CustomShipping\Plugin\Checkout\Block; use Magento\Checkout\Block\Checkout\LayoutProcessor; +/** + * Class LayoutProcessorPlugin + * @package bobgo\CustomShipping\Plugin\Checkout\Block + * This class is supposed to add a new field to the checkout page for the suburb. It is supposed to be used in conjunction with the SaveOrderBeforeSalesModelQuote observer. + * At the moment, it overrides the 2 Address fields and adds a new 3 Address field to accommodate the suburb on the checkout page( including placeholders). + * This is not the best way to do it, but it is the only way I could get it to work. + */ class LayoutProcessorPlugin { /** - * This is the Class That Allows The Field To Appear As Required On Checkout, - * But It Does Not Save The Data To The Quote Table In The Database For The Order - * To Be Processed Correctly In The Backend And Frontend It Works With Shipping - * Information Management Class - * @param LayoutProcessor $subject + * @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject * @param array $jsLayout * @return array */ + public function afterProcess( - LayoutProcessor $subject, + \Magento\Checkout\Block\Checkout\LayoutProcessor $subject, array $jsLayout - ): array - { - + ) { $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children'] - ['shippingAddress']['children']['shipping-address-fieldset']['children']['suburb'] = [ - 'component' => 'Magento_Ui/js/form/element/textarea', - 'config' => [ - 'customScope' => 'shippingAddress.extension_attributes', - 'customEntry' => null, - 'template' => 'ui/form/field', - 'elementTmpl' => 'ui/form/element/input', - 'options' => [], - 'tooltip' => [ - 'description' => __('Necessary for shipping.') - ], - 'id' => 'suburb' - ], - 'dataScope' => 'shippingAddress.extension_attributes.suburb', - 'label' => 'Suburb(BobGo Required)', + ['shippingAddress']['children']['shipping-address-fieldset']['children']['street'] = [ + 'component' => 'Magento_Ui/js/form/components/group', + 'label' => ('Street Address'), + 'required' => false, + 'dataScope' => 'shippingAddress.street', 'provider' => 'checkoutProvider', - 'visible' => false, - 'validation' => [ - 'required-entry' => false - ], - 'sortOrder' => 110, - /*'customEntry' => null,*/ - 'id' => 'suburb' + 'sortOrder' => 55, + 'type' => 'group', + 'additionalClasses' => 'street', + 'children' => [ + [ + 'label' => ('Street Address'), + 'component' => 'Magento_Ui/js/form/element/abstract', + 'config' => [ + 'placeholder' => 'street address', + 'customScope' => 'shippingAddress', + 'template' => 'ui/form/field', + 'elementTmpl' => 'ui/form/element/input' + ], + 'dataScope' => '0', + 'provider' => 'checkoutProvider', + 'validation' => ['required-entry' => true, "min_text_length" => 1, "max_text_length" => 255], + ], + [ + 'label' => __('Label 2'), + 'component' => 'Magento_Ui/js/form/element/abstract', + 'config' => [ + 'placeholder' => 'town', + 'customScope' => 'shippingAddress', + 'template' => 'ui/form/field', + 'elementTmpl' => 'ui/form/element/input' + ], + 'dataScope' => '1', + 'provider' => 'checkoutProvider', + 'validation' => ['required-entry' => true, "min_text_length" => 1, "max_text_length" => 255], + ], + [ + 'label' => __('Label 3'), + 'component' => 'Magento_Ui/js/form/element/abstract', + 'config' => [ + 'placeholder' => 'suburb', + 'customScope' => 'shippingAddress', + 'template' => 'ui/form/field', + 'elementTmpl' => 'ui/form/element/input' + ], + 'dataScope' => '2', + 'provider' => 'checkoutProvider', + 'validation' => ['required-entry' => true, "min_text_length" => 1, "max_text_length" => 255], + ], + 'dataScope' => '3', + 'provider' => 'checkoutProvider', + 'validation' => ['required-entry' => false, "min_text_length" => 1, "max_text_length" => 255], + ], ]; - return $jsLayout; } } diff --git a/Plugin/ShippingInformationManagement.php b/Plugin/ShippingInformationManagement.php index 24b2b3a2bd0dab29e31249256742bf5e23cffd7e..107f90be40122e915d33ec36a4773c26887e1824 100644 --- a/Plugin/ShippingInformationManagement.php +++ b/Plugin/ShippingInformationManagement.php @@ -1,11 +1,16 @@ <?php -namespace uafrica\Customshipping\Plugin; +namespace bobgo\CustomShipping\Plugin; use Magento\Quote\Api\CartRepositoryInterface; use Magento\Checkout\Api\Data\ShippingInformationInterface; +/** + * Class ShippingInformationManagement + * @package bobgo\CustomShipping\Plugin + * This class is supposed to copy the suburb attribute from the quote to the order object. + */ class ShippingInformationManagement { public CartRepositoryInterface $cartRepository; @@ -17,7 +22,7 @@ class ShippingInformationManagement $this->cartRepository = $cartRepository; } - public function beforeSaveAddressInformation($subject, $cartId, ShippingInformationInterface $addressInformation) + public function beforeSaveAddressInformation($subject, $cartId, ShippingInformationInterface $addressInformation): array { $quote = $this->cartRepository->getActive($cartId); $deliveryNote = $addressInformation->getShippingAddress()->getExtensionAttributes()->getSuburb(); diff --git a/Readme.md b/Readme.md index f9d0d6c8ed7881381a70796b84d2e2a6e1bbd2bc..c157860761a1071e29e6ce76907d3e857a5ae810 100644 --- a/Readme.md +++ b/Readme.md @@ -1,17 +1,17 @@ -# Magento 2 uAfrica Shipping Extension +# Magento 2 BobGo Shipping Extension ## Introduction -A complete guide to install Magento uAfrica Shipping extension in Magento 2. +A complete guide to install Magento Bob Go Shipping extension in Magento 2. ## Features ->This extension allows you to get real-time shipping rates from BobGo shipping services and display them to your customers during checkout. +>This extension allows you to get real-time shipping rates from Bob Go shipping services and display them to your customers during checkout. ->This extension also allows you to track shipments and get delivery status updates from BobGo shipping services. +>This extension also allows you to track shipments and get delivery status updates from Bob Go shipping services. -## How to install Magento 2 Bobgo Shipping Extension +## How to install Magento 2 Bob Go Shipping Extension ### Option 1 (recommended): Install via composer @@ -23,12 +23,12 @@ Run the following command in Magento 2 root folder:</br> #### 1. Execute the following command to install the module: ``` -composer require uafrica/customshipping +composer require bobgo/CustomShipping ``` #### 2. Enter following commands to enable the module: ``` -bin/magento module:enable uafrica_Customshipping +bin/magento module:enable bobgo_CustomShipping bin/magento cache:clean bin/magento cache:flush bin/magento setup:upgrade @@ -41,20 +41,20 @@ bin/magento setup:static-content:deploy 1. Download the extension zip file from the link below: </br> - <a href="https://github.com/uafrica/magento-uafrica-shipping-extension/archive/refs/heads/main.zip"> Download Magento 2 uAfrica Shipping Extension </a> + <a href="https://gitlab.bob.co.za/bobgo/bobgo-magento-extension/-/archive/main/bobgo-magento-extension-main.zip"> Download Magento 2 Bob Go Shipping Extension </a> 2. Unzip the file and copy contents -3. Create `uafrica/Customshipping` <em>Directory</em> +3. Create `bobgo/CustomShipping` <em>Directory</em> **It should look like this:** </br> ->{Magento root}/app/code/uafrica/Customshipping/ +>{Magento root}/app/code/bobgo/CustomShipping/ ->**{Magento root}**`/app/code/uafrica/Customshipping/`**{Paste here}** +>**{Magento root}**`/app/code/bobgo/CustomShipping/`**{Paste here}** -3. Go to Magento root folder and run all commands below to install `uafrica_Customshipping`: </br> +3. Go to Magento root folder and run all commands below to install `bobgo_CustomShipping`: </br> ``` bin/magento cache:clean Bin/magento cache:flush @@ -65,22 +65,22 @@ ________________________________________________________________________________ # After installation -## How to configure Magento 2 uAfrica Shipping Extension +## How to configure Magento 2 Bob Go Shipping Extension -### ✓ Step 1: Create an account on Bobgo +### ✓ Step 1: Create an account on Bob Go -You need to create an account on Bobgo to get your Store Identified by the API. +You need to create an account on Bob Go to get your Store Identified by the API. -Please visit [Bobgo](https://uafrica.co.za) to create an account. +Please visit [Bob Go](https://bobgo.co.za) to create an account. ### ✓ Step 2: Login to Magento Admin -1. Click on **UAFRICA** > bobGo > Enabled for Checkout > Yes </br> +1. Click on **bobgo** > bobGo > Enabled for Checkout > Yes </br> 2. and go to `Stores > Configuration > Sales > Delivery Methods` to configure the extension. -### ✓ Step 3: Configure Bobgo Shipping Extension +### ✓ Step 3: Configure Bob Go Shipping Extension 1. Select `Bobgo` as shipping method. @@ -110,13 +110,13 @@ When the extension is **installed** and **enabled**, a new field will be created ## How it works -## How to use Magento 2 Bobgo Shipping Extension (carrier) to Ship Orders +## How to use Magento 2 Bob Go Shipping Extension (carrier) to Ship Orders ### ✓ Step 1: Add products to cart(Checkout) >1. Go to checkout page. >2. Select shipping address. ->3. BobGo will collect **Shipping Rates** From various couriers. +>3. Bob Go will collect **Shipping Rates** From various couriers. >4. Select shipping method. >5. Place order. @@ -126,5 +126,5 @@ When the extension is **installed** and **enabled**, a new field will be created >1. Go to `Sales > Orders` in Magento Admin >2. Select an order >3. Click `Ship` button ->4. Select `uAfrica` as shipping method +>4. Select `bobgo` as shipping method >5. Click `Submit Shipment` button diff --git a/composer.json b/composer.json index 8168ba4b1181dadc2a09d5f554b2e78359d21ee0..d817decda90ccb35b62a7d9d1a542d42ea8fe6f4 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,12 @@ { - "name": "uafrica/bobgo", - "description": "Streamline your shipments fulfillments with bobgo", + "name": "bobgo/bobgo", + "description": "Streamline your shipments fulfillment's with bobgo", "type": "magento2-module", "version": "1.0.0", "authors": [ { - "name": "Gundo", - "email": "gundo@bob.co.za", + "name": "Bob Go", + "email": "info@bob.co.za", "homepage": "https://www.bob.co.za" } ], @@ -19,7 +19,7 @@ "registration.php" ], "psr-4": { - "uafrica\\Customshipping\\": "" + "bobgo\\CustomShipping\\": "" } } } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 792020a3143a4ee6abca203b862f674a96b01121..84025e6eeeb55c581cb08ccf469b8461e5612bc8 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -1,26 +1,26 @@ <?xml version="1.0"?> <!-- /** - * @category Uafrica - * @package Uafrica_Customshipping - * @author Uafrica + * @category bobgo + * @package bobgo_CustomShipping + * @author bobgo */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> <system> - <tab id="uafrica" translate="label" sortOrder="200"> - <label>uafrica</label> + <tab id="bobgo" translate="label" sortOrder="200"> + <label>Bob Go</label> </tab> - <section id="uafrica_customshipping" showInDefault="1"> - <tab>uafrica</tab> - <label>bobGo</label> + <section id="bobgo_CustomShipping" showInDefault="1"> + <tab>BobGo</tab> + <label>Bob Go</label> <resource>Magento_Config::config</resource> <group id="general" showInDefault="1"> <label>General Settings</label> <field id="version" translate="label" type="label" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0"> <label>Version</label> - <frontend_model>uafrica\Customshipping\Block\System\Config\Form\Field\Version</frontend_model> + <frontend_model>bobgo\CustomShipping\Block\System\Config\Form\Field\Version</frontend_model> </field> <field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Enabled for Checkout</label> @@ -41,12 +41,12 @@ </group> </section> <section id="carriers" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> - <group id="uafrica" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>uAfrica</label> + <group id="bobgo" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>bobgo</label> <field id="version" translate="label" type="label" sortOrder="0" showInDefault="1" showInWebsite="0" showInStore="0"> <label>Version</label> - <frontend_model>uafrica\Customshipping\Block\System\Config\Form\Field\Version</frontend_model> + <frontend_model>bobgo\CustomShipping\Block\System\Config\Form\Field\Version</frontend_model> </field> <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> @@ -86,7 +86,7 @@ </field> <field id="unit_of_measure" translate="label" type="select" sortOrder="73" showInDefault="1" showInWebsite="1" canRestore="1"> <label>Weight Unit</label> - <source_model>uafrica\Customshipping\Model\Source\Unitofmeasure</source_model> + <source_model>bobgo\CustomShipping\Model\Source\Unitofmeasure</source_model> </field> <field id="additional_info" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1"> <label>Display Additional Information</label> diff --git a/etc/config.xml b/etc/config.xml index eeba0c66da7f010bc660fa9aa0ae42d65681738b..aa8f79dfde17814e8deff10dd15e1a395b4a4f7a 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,29 +1,29 @@ <?xml version="1.0"?> <!-- /** - * @category Uafrica - * @package Uafrica_Customshipping - * @author Uafrica + * @category bobgo + * @package bobgo_CustomShipping + * @author bobgo */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> <default> - <uafrica_customshipping> + <bobgo_CustomShipping> <general> <debug>0</debug> </general> - </uafrica_customshipping> + </bobgo_CustomShipping> <carriers> - <uafrica> + <bobgo> <active>0</active> <sallowspecific>0</sallowspecific> <price>0.00</price> - <model>uafrica\Customshipping\Model\Carrier\Customshipping</model> + <model>bobgo\CustomShipping\Model\Carrier\CustomShipping</model> <name>Fixed</name> - <title>uAfrica</title> + <title>Bob Go</title> <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg> - </uafrica> + </bobgo> </carriers> </default> diff --git a/etc/di.xml b/etc/di.xml index f93b3182a2951ab815b2deabe8105d67dd836147..4f4ee2d8bbfd191d93355cbc58931211a3be53b2 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -3,6 +3,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Checkout\Model\ShippingInformationManagement"> <plugin name="get_suburb" - type="uafrica\Customshipping\Plugin\ShippingInformationManagement" sortOrder="1"/> + type="bobgo\CustomShipping\Plugin\ShippingInformationManagement" sortOrder="1"/> </type> </config> diff --git a/etc/events.xml b/etc/events.xml index c54fd93b7597557cc6c21f8fcc90e712dc54c5ae..caf07f224582cd023691b1d43ed3d5d5052c75b5 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Event/etc/events.xsd"> <event name="sales_model_service_quote_submit_before"> - <observer name="uafrica_customshipping_sales_model_service_quote_submit_before" - instance="uafrica\Customshipping\Observer\SaveOrderBeforeSalesModelQuote" /> + <observer name="bobgo_CustomShipping_sales_model_service_quote_submit_before" + instance="bobgo\CustomShipping\Observer\SaveOrderBeforeSalesModelQuote" /> </event> </config> diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index a06930c7ab62a170f5960aab4fb2c2026509886f..61b1ccdd5598615f49d8e63f90f0bbff6a2ccf20 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -1,9 +1,9 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Checkout\Block\Checkout\LayoutProcessor"> - <plugin name="add_custom_field_checkout_shipping_form" type="uafrica\Customshipping\Plugin\Checkout\Block\LayoutProcessorPlugin" sortOrder="10"/> + <plugin name="add_custom_field_checkout_shipping_form" type="bobgo\CustomShipping\Plugin\Checkout\Block\LayoutProcessorPlugin" sortOrder="10"/> <arguments> <argument name="layoutProcessors" xsi:type="array"> - <item name="orderattribute" xsi:type="object">uafrica\Customshipping\Plugin\Checkout\Block\LayoutProcessorPlugin</item> + <item name="orderattribute" xsi:type="object">bobgo\CustomShipping\Plugin\Checkout\Block\LayoutProcessorPlugin</item> </argument> </arguments> </type> diff --git a/etc/module.xml b/etc/module.xml index 8c5f805a7f40344c403f95af89f805806299756f..c1a03f842063b0354d514b7003300f63e321ca36 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,13 +1,13 @@ <?xml version="1.0"?> <!-- /** - * @category Uafrica - * @package Uafrica_Customshipping - * @author Uafrica + * @category bobgo + * @package bobgo_CustomShipping + * @author bobgo */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="uafrica_Customshipping" setup_version="1.0.0"> + <module name="bobgo_CustomShipping" setup_version="1.0.0"> <sequence> <module name="Magento_Webapi"/> <module name="Magento_Catalog"/> diff --git a/registration.php b/registration.php index 3874a8c7c571621285294fb2e7411bbc0c4b18d7..4c358c2e4db661b29186feaf09f205555534fa69 100644 --- a/registration.php +++ b/registration.php @@ -1,6 +1,7 @@ <?php +// Convention requires Vendor_Extension \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'uafrica_Customshipping', + 'bobgo_CustomShipping', __DIR__ ); diff --git a/vendor/autoload.php b/vendor/autoload.php deleted file mode 100644 index d52a5a24374833000273ce7b261db635c70dc97f..0000000000000000000000000000000000000000 --- a/vendor/autoload.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -// autoload.php @generated by Composer - -if (PHP_VERSION_ID < 50600) { - if (!headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - } - $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; - if (!ini_get('display_errors')) { - if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { - fwrite(STDERR, $err); - } elseif (!headers_sent()) { - echo $err; - } - } - trigger_error( - $err, - E_USER_ERROR - ); -} - -require_once __DIR__ . '/composer/autoload_real.php'; - -return ComposerAutoloaderInit9ef748c64c226893f336031e47dd147d::getLoader(); diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php deleted file mode 100644 index 1abd427cf1afa3a841c0acfeace634b3009815db..0000000000000000000000000000000000000000 --- a/vendor/composer/ClassLoader.php +++ /dev/null @@ -1,571 +0,0 @@ -<?php - -/* - * This file is part of Composer. - * - * (c) Nils Adermann <naderman@naderman.de> - * Jordi Boggiano <j.boggiano@seld.be> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier <fabien@symfony.com> - * @author Jordi Boggiano <j.boggiano@seld.be> - * @see https://www.php-fig.org/psr/psr-0/ - * @see https://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - /** @var ?string */ - private $vendorDir; - - // PSR-4 - /** - * @var array[] - * @psalm-var array<string, array<string, int>> - */ - private $prefixLengthsPsr4 = array(); - /** - * @var array[] - * @psalm-var array<string, array<int, string>> - */ - private $prefixDirsPsr4 = array(); - /** - * @var array[] - * @psalm-var array<string, string> - */ - private $fallbackDirsPsr4 = array(); - - // PSR-0 - /** - * @var array[] - * @psalm-var array<string, array<string, string[]>> - */ - private $prefixesPsr0 = array(); - /** - * @var array[] - * @psalm-var array<string, string> - */ - private $fallbackDirsPsr0 = array(); - - /** @var bool */ - private $useIncludePath = false; - - /** - * @var string[] - * @psalm-var array<string, string> - */ - private $classMap = array(); - - /** @var bool */ - private $classMapAuthoritative = false; - - /** - * @var bool[] - * @psalm-var array<string, bool> - */ - private $missingClasses = array(); - - /** @var ?string */ - private $apcuPrefix; - - /** - * @var self[] - */ - private static $registeredLoaders = array(); - - /** - * @param ?string $vendorDir - */ - public function __construct($vendorDir = null) - { - $this->vendorDir = $vendorDir; - } - - /** - * @return string[] - */ - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); - } - - return array(); - } - - /** - * @return array[] - * @psalm-return array<string, array<int, string>> - */ - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - /** - * @return array[] - * @psalm-return array<string, string> - */ - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - /** - * @return array[] - * @psalm-return array<string, string> - */ - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - /** - * @return string[] Array of classname => path - * @psalm-return array<string, string> - */ - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param string[] $classMap Class to filename map - * @psalm-param array<string, string> $classMap - * - * @return void - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - * - * @return void - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories - * - * @return void - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - * - * @return void - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - * - * @return void - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. - * - * @param string|null $apcuPrefix - * - * @return void - */ - public function setApcuPrefix($apcuPrefix) - { - $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; - } - - /** - * The APCu prefix in use, or null if APCu caching is not enabled. - * - * @return string|null - */ - public function getApcuPrefix() - { - return $this->apcuPrefix; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - * - * @return void - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - - if (null === $this->vendorDir) { - return; - } - - if ($prepend) { - self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; - } else { - unset(self::$registeredLoaders[$this->vendorDir]); - self::$registeredLoaders[$this->vendorDir] = $this; - } - } - - /** - * Unregisters this instance as an autoloader. - * - * @return void - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - - if (null !== $this->vendorDir) { - unset(self::$registeredLoaders[$this->vendorDir]); - } - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return true|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - - return null; - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { - return false; - } - if (null !== $this->apcuPrefix) { - $file = apcu_fetch($this->apcuPrefix.$class, $hit); - if ($hit) { - return $file; - } - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if (null !== $this->apcuPrefix) { - apcu_add($this->apcuPrefix.$class, $file); - } - - if (false === $file) { - // Remember that this class does not exist. - $this->missingClasses[$class] = true; - } - - return $file; - } - - /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. - * - * @return self[] - */ - public static function getRegisteredLoaders() - { - return self::$registeredLoaders; - } - - /** - * @param string $class - * @param string $ext - * @return string|false - */ - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = ClassLoader . phpstrtr($class, '\\', DIRECTORY_SEPARATOR); - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - $subPath = $class; - while (false !== $lastPos = strrpos($subPath, '\\')) { - $subPath = substr($subPath, 0, $lastPos); - $search = $subPath . '\\'; - if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); - foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = ClassLoader . phpsubstr($logicalPathPsr4, 0, $pos + 1); - } else { - // PEAR-like class name - $logicalPathPsr0 = ClassLoader . phpstrtr($class, '_', DIRECTORY_SEPARATOR); - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - - return false; - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - * @private - */ -function includeFile($file) -{ - include $file; -} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php deleted file mode 100644 index c6b54af7ba2e1e3e960134233321efe47aa4528c..0000000000000000000000000000000000000000 --- a/vendor/composer/InstalledVersions.php +++ /dev/null @@ -1,352 +0,0 @@ -<?php - -/* - * This file is part of Composer. - * - * (c) Nils Adermann <naderman@naderman.de> - * Jordi Boggiano <j.boggiano@seld.be> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer; - -use Composer\Autoload\ClassLoader; -use Composer\Semver\VersionParser; - -/** - * This class is copied in every Composer installed project and available to all - * - * See also https://getcomposer.org/doc/07-runtime.md#installed-versions - * - * To require its presence, you can require `composer-runtime-api ^2.0` - * - * @final - */ -class InstalledVersions -{ - /** - * @var mixed[]|null - * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null - */ - private static $installed; - - /** - * @var bool|null - */ - private static $canGetVendors; - - /** - * @var array[] - * @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> - */ - private static $installedByVendor = array(); - - /** - * Returns a list of all package names which are present, either by being installed, replaced or provided - * - * @return string[] - * @psalm-return list<string> - */ - public static function getInstalledPackages() - { - $packages = array(); - foreach (self::getInstalled() as $installed) { - $packages[] = array_keys($installed['versions']); - } - - if (1 === \count($packages)) { - return $packages[0]; - } - - return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); - } - - /** - * Returns a list of all package names with a specific type e.g. 'library' - * - * @param string $type - * @return string[] - * @psalm-return list<string> - */ - public static function getInstalledPackagesByType($type) - { - $packagesByType = array(); - - foreach (self::getInstalled() as $installed) { - foreach ($installed['versions'] as $name => $package) { - if (isset($package['type']) && $package['type'] === $type) { - $packagesByType[] = $name; - } - } - } - - return $packagesByType; - } - - /** - * Checks whether the given package is installed - * - * This also returns true if the package name is provided or replaced by another package - * - * @param string $packageName - * @param bool $includeDevRequirements - * @return bool - */ - public static function isInstalled($packageName, $includeDevRequirements = true) - { - foreach (self::getInstalled() as $installed) { - if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); - } - } - - return false; - } - - /** - * Checks whether the given package satisfies a version constraint - * - * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: - * - * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') - * - * @param VersionParser $parser Install composer/semver to have access to this class and functionality - * @param string $packageName - * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package - * @return bool - */ - public static function satisfies(VersionParser $parser, $packageName, $constraint) - { - $constraint = $parser->parseConstraints($constraint); - $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); - - return $provided->matches($constraint); - } - - /** - * Returns a version constraint representing all the range(s) which are installed for a given package - * - * It is easier to use this via isInstalled() with the $constraint argument if you need to check - * whether a given version of a package is installed, and not just whether it exists - * - * @param string $packageName - * @return string Version constraint usable with composer/semver - */ - public static function getVersionRanges($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - $ranges = array(); - if (isset($installed['versions'][$packageName]['pretty_version'])) { - $ranges[] = $installed['versions'][$packageName]['pretty_version']; - } - if (array_key_exists('aliases', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); - } - if (array_key_exists('replaced', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); - } - if (array_key_exists('provided', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); - } - - return implode(' || ', $ranges); - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['version'])) { - return null; - } - - return $installed['versions'][$packageName]['version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getPrettyVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['pretty_version'])) { - return null; - } - - return $installed['versions'][$packageName]['pretty_version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference - */ - public static function getReference($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['reference'])) { - return null; - } - - return $installed['versions'][$packageName]['reference']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. - */ - public static function getInstallPath($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @return array - * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} - */ - public static function getRootPackage() - { - $installed = self::getInstalled(); - - return $installed[0]['root']; - } - - /** - * Returns the raw installed.php data for custom implementations - * - * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. - * @return array[] - * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} - */ - public static function getRawData() - { - @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = include __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } - - return self::$installed; - } - - /** - * Returns the raw data of all installed.php which are currently loaded for custom implementations - * - * @return array[] - * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> - */ - public static function getAllRawData() - { - return self::getInstalled(); - } - - /** - * Lets you reload the static array from another file - * - * This is only useful for complex integrations in which a project needs to use - * this class but then also needs to execute another project's autoloader in process, - * and wants to ensure both projects have access to their version of installed.php. - * - * A typical case would be PHPUnit, where it would need to make sure it reads all - * the data it needs from this class, then call reload() with - * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure - * the project in which it runs can then also use this class safely, without - * interference between PHPUnit's dependencies and the project's dependencies. - * - * @param array[] $data A vendor/composer/installed.php data set - * @return void - * - * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data - */ - public static function reload($data) - { - self::$installed = $data; - self::$installedByVendor = array(); - } - - /** - * @return array[] - * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> - */ - private static function getInstalled() - { - if (null === self::$canGetVendors) { - self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); - } - - $installed = array(); - - if (self::$canGetVendors) { - foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { - if (isset(self::$installedByVendor[$vendorDir])) { - $installed[] = self::$installedByVendor[$vendorDir]; - } elseif (is_file($vendorDir.'/composer/installed.php')) { - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; - } - } - } - } - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } - $installed[] = self::$installed; - - return $installed; - } -} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE deleted file mode 100644 index f27399a042d95c4708af3a8c74d35d338763cf8f..0000000000000000000000000000000000000000 --- a/vendor/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php deleted file mode 100644 index 0fb0a2c194b8590999a5ed79e357d4a9c1e9d8b8..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -// autoload_classmap.php @generated by Composer - -$vendorDir = dirname(__DIR__); -$baseDir = dirname($vendorDir); - -return array( - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', -); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php deleted file mode 100644 index 15a2ff3ad6d8d6ea2b6b1f9552c62d745ffc9bf4..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_namespaces.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -// autoload_namespaces.php @generated by Composer - -$vendorDir = dirname(__DIR__); -$baseDir = dirname($vendorDir); - -return array( -); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php deleted file mode 100644 index 3890ddc2409b78e2720b8ec2db64d76b18811b3d..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_psr4.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -// autoload_psr4.php @generated by Composer - -$vendorDir = dirname(__DIR__); -$baseDir = dirname($vendorDir); - -return array( -); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php deleted file mode 100644 index b1dde79b7be6fde981dc5e958df98950d975ba53..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_real.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -// autoload_real.php @generated by Composer - -class ComposerAutoloaderInit9ef748c64c226893f336031e47dd147d -{ - private static $loader; - - public static function loadClassLoader($class) - { - if ('Composer\Autoload\ClassLoader' === $class) { - require __DIR__ . '/ClassLoader.php'; - } - } - - /** - * @return \Composer\Autoload\ClassLoader - */ - public static function getLoader() - { - if (null !== self::$loader) { - return self::$loader; - } - - spl_autoload_register(array('ComposerAutoloaderInit9ef748c64c226893f336031e47dd147d', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit9ef748c64c226893f336031e47dd147d', 'loadClassLoader')); - - require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit9ef748c64c226893f336031e47dd147d::getInitializer($loader)); - - $loader->register(true); - - return $loader; - } -} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php deleted file mode 100644 index 5703da56a26aa4d38ddbfe3c1d3afc98b691aa4c..0000000000000000000000000000000000000000 --- a/vendor/composer/autoload_static.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -// autoload_static.php @generated by Composer - -namespace Composer\Autoload; - -class ComposerStaticInit9ef748c64c226893f336031e47dd147d -{ - public static $classMap = array ( - 'Composer\\InstalledVersions' => __DIR__ . '/..', - ); - - public static function getInitializer(ClassLoader $loader) - { - return \Closure::bind(function () use ($loader) { - $loader->classMap = ComposerStaticInit9ef748c64c226893f336031e47dd147d::$classMap; - - }, null, ClassLoader::class); - } -} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json deleted file mode 100644 index 87fda747e6ce957c1bf1b4d373bb5c60dbf96e7d..0000000000000000000000000000000000000000 --- a/vendor/composer/installed.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "packages": [], - "dev": true, - "dev-package-names": [] -} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php deleted file mode 100644 index 9e79e7e740d968ce8d00bdc05cdbe83de6a2da3a..0000000000000000000000000000000000000000 --- a/vendor/composer/installed.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php return array( - 'root' => array( - 'name' => '__root__', - 'pretty_version' => 'dev-main', - 'version' => 'dev-main', - 'reference' => '5d71c85cc020f9db5753213fce46620f15cb94d1', - 'type' => 'library', - 'install_path' => __DIR__ . '/../magento-uafrica-shipping-extension/', - 'aliases' => array(), - 'dev' => true, - ), - 'versions' => array( - '__root__' => array( - 'pretty_version' => 'dev-main', - 'version' => 'dev-main', - 'reference' => '5d71c85cc020f9db5753213fce46620f15cb94d1', - 'type' => 'library', - 'install_path' => __DIR__ . '/../magento-uafrica-shipping-extension/', - 'aliases' => array(), - 'dev_requirement' => false, - ), - ), -); diff --git a/view/frontend/layout/checkout_cart_index.xml b/view/frontend/layout/checkout_cart_index.xml index 2c08acb3437459f52f010a28450a53ab6d43dd21..884a7712c0b183d822204c85f434ee9c250ec4ab 100644 --- a/view/frontend/layout/checkout_cart_index.xml +++ b/view/frontend/layout/checkout_cart_index.xml @@ -9,8 +9,8 @@ <item name="children" xsi:type="array"> <item name="shipping-rates-validation" xsi:type="array"> <item name="children" xsi:type="array"> - <item name="uafrica-rates-validation" xsi:type="array"> - <item name="component" xsi:type="string">uafrica_Customshipping/js/view/shipping-rates-validation</item> + <item name="bobgo-rates-validation" xsi:type="array"> + <item name="component" xsi:type="string">bobgo_CustomShipping/js/view/shipping-rates-validation</item> </item> </item> </item> diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 3d41b4eac5eb388c255204ad196ae32b769ec5f5..95457b70f16c695dc1869519860fbdb73f1f94a1 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -15,8 +15,8 @@ <item name="children" xsi:type="array"> <item name="shipping-rates-validation" xsi:type="array"> <item name="children" xsi:type="array"> - <item name="uafrica-rates-validation" xsi:type="array"> - <item name="component" xsi:type="string">uafrica_Customshipping/js/view/shipping-rates-validation</item> + <item name="bobgo-rates-validation" xsi:type="array"> + <item name="component" xsi:type="string">bobgo_CustomShipping/js/view/shipping-rates-validation</item> </item> </item> </item> diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js index 79d332fcf0aba003f083425c3afde641c35733df..471dc742f1a6068b0d02ccbfeba883f771eab8ff 100644 --- a/view/frontend/requirejs-config.js +++ b/view/frontend/requirejs-config.js @@ -1,8 +1,10 @@ +/*required for adding the mixing that is supposed to add the suburb to the shipping address +set-shipping-information-mixin.js*/ var config = { config: { mixins: { 'Magento_Checkout/js/action/set-shipping-information': { - 'uafrica_Customshipping/js/action/set-shipping-information-mixin': true + 'bobgo_CustomShipping/js/action/set-shipping-information-mixin': true } } } diff --git a/view/frontend/web/js/action/set-shipping-information-mixin.js b/view/frontend/web/js/action/set-shipping-information-mixin.js index 1c8327be8ca8e09070cdddcbb8b065c709988745..b899f21c19c365149aeac59026048b30e3d322fa 100644 --- a/view/frontend/web/js/action/set-shipping-information-mixin.js +++ b/view/frontend/web/js/action/set-shipping-information-mixin.js @@ -14,18 +14,19 @@ define([ if (shippingAddress['extension_attributes'] === undefined) { shippingAddress['extension_attributes'] = {}; } + //This is supposed to be the mixin that adds the suburb to the shipping address, but it doesn't work +/* var attribute = shippingAddress.customAttributes.find( + function (element) { + return element.attribute_code === 'suburb'; + } + ); - // var attribute = shippingAddress.customAttributes.find( - // function (element) { - // return element.attribute_code === 'suburb'; - // } - // ); - // - // shippingAddress['extension_attributes']['suburb'] = attribute.value; + shippingAddress['extension_attributes']['suburb'] = attribute.value; - // shippingAddress['extension_attributes']['suburb'] = shippingAddress.value; + shippingAddress['extension_attributes']['suburb'] = shippingAddress.value; - // pass execution to original action ('Magento_Checkout/js/action/set-shipping-information') + pass execution to original action ('Magento_Checkout/js/action/set-shipping-information')*/ + //after all the of the above the suburb is still not added to the request payload that goes to CustomShipping.php return originalAction(); }); }; diff --git a/view/frontend/web/js/model/shipping-rates-validation-rules.js b/view/frontend/web/js/model/shipping-rates-validation-rules.js index 0cf80ca2a58009b4055a599fac3a7d4d45a2e799..0841e9095170ae18c60fd4f95c563b39235f077a 100644 --- a/view/frontend/web/js/model/shipping-rates-validation-rules.js +++ b/view/frontend/web/js/model/shipping-rates-validation-rules.js @@ -18,9 +18,6 @@ define( }, 'city': { 'required': true - }, - 'suburb': { - 'required': true } }; } diff --git a/view/frontend/web/js/view/shipping-rates-validation.js b/view/frontend/web/js/view/shipping-rates-validation.js index bfe148b4ad02dd6ee67588cf6c06fed1f2c09835..492fb9acf901a5643ae057266f9ca613a3fbb622 100644 --- a/view/frontend/web/js/view/shipping-rates-validation.js +++ b/view/frontend/web/js/view/shipping-rates-validation.js @@ -20,8 +20,8 @@ define( sampleShippingProviderShippingRatesValidationRules ) { "use strict"; - defaultShippingRatesValidator.registerValidator('uafrica', sampleShippingProviderShippingRatesValidator); - defaultShippingRatesValidationRules.registerRules('uafrica', sampleShippingProviderShippingRatesValidationRules); + defaultShippingRatesValidator.registerValidator('bobgo', sampleShippingProviderShippingRatesValidator); + defaultShippingRatesValidationRules.registerRules('bobgo', sampleShippingProviderShippingRatesValidationRules); return Component; } );