diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index 36bb2fa..0000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -engines: - duplication: - enabled: true - config: - languages: - - javascript - - php - eslint: - enabled: true - fixme: - enabled: true - phan: - enabled: true - config: - file_extensions: php - ignore-undeclared: true -ratings: - paths: - - "**.js" - - "**.php" -exclude_paths: - - src/*/Test - - vendor/* - - Resources/* diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..14e897f --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +/.github export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/CHANGELOG.md export-ignore +/phpcs.xml.dist export-ignore +/phpmd.xml.dist export-ignore +/phpstan.neon.dist export-ignore +/README.md export-ignore diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml new file mode 100644 index 0000000..3ebefff --- /dev/null +++ b/.github/workflows/static-analysis.yaml @@ -0,0 +1,66 @@ +name: 'Static Analysis' + +on: + pull_request: ~ + push: + branches: + - 'master' + +jobs: + static-analysis: + runs-on: 'ubuntu-latest' + + strategy: + matrix: + php-version: + - '8.1' + + steps: + - name: 'Checkout' + uses: 'actions/checkout@v3' + + - name: 'Install PHP' + uses: 'shivammathur/setup-php@v2' + with: + php-version: '${{ matrix.php-version }}' + coverage: 'none' + tools: 'composer:v2' + env: + COMPOSER_AUTH_JSON: | + { + "http-basic": { + "repo.magento.com": { + "username": "${{ secrets.MAGENTO_USERNAME }}", + "password": "${{ secrets.MAGENTO_PASSWORD }}" + } + } + } + + - name: 'Get composer cache directory' + id: 'composer-cache' + run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT' + + - name: 'Cache dependencies' + uses: 'actions/cache@v3' + with: + path: '${{ steps.composer-cache.outputs.dir }}' + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: '${{ runner.os }}-composer-' + + - name: 'Install dependencies' + run: 'composer install --prefer-dist' + + - name: 'Run composer audit' + run: 'composer audit --format=plain' + + - name: 'Run Parallel Lint' + run: 'vendor/bin/parallel-lint --exclude vendor .' + + - name: 'Run PHP CodeSniffer' + run: 'vendor/bin/phpcs --extensions=php,phtml' + + - name: 'Run PHPMD' + run: 'vendor/bin/phpmd . xml phpmd.xml.dist' + +# - name: 'Run PHPStan' +# run: 'vendor/bin/phpstan analyse' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..437d97f --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.fleet +/.idea +/vendor +/composer.lock +/phpcs.xml +/phpstan.neon diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 52aa001..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: php - -php: -- '5.6' -- '7.0' - -install: [ - "mkdir -p app/etc var", - "echo \"{\\\"http-basic\\\":{\\\"repo.magento.com\\\":{\\\"username\\\":\\\"${MAGENTO_USERNAME}\\\",\\\"password\\\":\\\"${MAGENTO_PASSWORD}\\\"}}}\" > auth.json", - "composer install --prefer-dist" -] - -cache: - directories: - - $HOME/.composer/cache - -script: - - vendor/bin/phpcs --config-set installed_paths vendor/magento/marketplace-eqp/ - - vendor/bin/phpcs --standard=vendor/magento/marketplace-eqp/MEQP2 --ignore=vendor,pub --severity=9 ./ - - vendor/bin/phpcs --standard=vendor/smile/magento2-smilelab-phpcs/phpcs-standards/SmileLab --ignore=vendor,pub --extensions=php ./ - - vendor/bin/phpmd ./ text vendor/smile/magento2-smilelab-phpmd/phpmd-rulesets/rulset.xml --exclude vendor,pub diff --git a/Block/Checkout/LayoutProcessor.php b/Block/Checkout/LayoutProcessor.php index 902d23b..d72df6b 100644 --- a/Block/Checkout/LayoutProcessor.php +++ b/Block/Checkout/LayoutProcessor.php @@ -1,121 +1,52 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + +declare(strict_types=1); + namespace Smile\StoreDelivery\Block\Checkout; use Magento\Checkout\Block\Checkout\LayoutProcessorInterface; +use Magento\Framework\App\CacheInterface; +use Magento\Framework\DataObject; +use Magento\Framework\UrlInterface; use Magento\Shipping\Model\CarrierFactoryInterface; use Smile\Map\Api\MapInterface; +use Smile\Map\Api\MapProviderInterface; use Smile\Map\Model\AddressFormatter; +use Smile\Retailer\Api\Data\RetailerExtensionInterface; use Smile\Retailer\Api\Data\RetailerInterface; +use Smile\Retailer\Model\ResourceModel\Retailer\Collection; use Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory; +use Smile\StoreDelivery\Model\Carrier; +use Smile\StoreLocator\Api\Data\RetailerAddressInterface; +use Smile\StoreLocator\Helper\Data; +use Smile\StoreLocator\Helper\Schedule; +use Smile\StoreLocator\Model\Retailer\ScheduleManagement; /** * Specific JS Layout processor for StoreDelivery. * Inject Map, Geolocation and Stores into checkout UI Components. - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud */ class LayoutProcessor implements LayoutProcessorInterface { - /** - * @var string - */ - private $methodCode = \Smile\StoreDelivery\Model\Carrier::METHOD_CODE; - - /** - * @var MapInterface - */ - private $map; - - /** - * @var CollectionFactory - */ - private $retailerCollectionFactory; - - /** - * @var \Smile\StoreLocator\Helper\Data - */ - private $storeLocatorHelper; - - /** - * @var \Smile\Map\Model\AddressFormatter - */ - private $addressFormatter; + private string $methodCode = Carrier::METHOD_CODE; + private MapInterface $map; - /** - * @var \Smile\StoreLocator\Helper\Schedule - */ - private $scheduleHelper; - - /** - * @var \Smile\StoreLocator\Model\Retailer\ScheduleManagement - */ - private $scheduleManager; - - /** - * @var \Magento\Shipping\Model\CarrierFactoryInterface - */ - private $carrierFactory; - - /** - * @var \Magento\Framework\UrlInterface - */ - private $urlBuilder; - - /** - * @var \Magento\Framework\App\CacheInterface - */ - private $cache; - - /** - * Constructor. - * - * @param \Smile\Map\Api\MapProviderInterface $mapProvider Map provider. - * @param \Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory $retailerCollectionFactory Retailer collection factory. - * @param \Smile\StoreLocator\Helper\Data $storeLocatorHelper Store locator helper. - * @param \Smile\Map\Model\AddressFormatter $addressFormatter Address formatter tool. - * @param \Smile\StoreLocator\Helper\Schedule $scheduleHelper Schedule Helper - * @param \Smile\StoreLocator\Model\Retailer\ScheduleManagement $scheduleManagement Schedule Management - * @param CarrierFactoryInterface $carrierFactory Carrier Factory - * @param \Magento\Framework\UrlInterface $urlBuilder URL Builder - * @param \Magento\Framework\App\CacheInterface $cacheInterface Cache Interface - */ public function __construct( - \Smile\Map\Api\MapProviderInterface $mapProvider, - \Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory $retailerCollectionFactory, - \Smile\StoreLocator\Helper\Data $storeLocatorHelper, - \Smile\Map\Model\AddressFormatter $addressFormatter, - \Smile\StoreLocator\Helper\Schedule $scheduleHelper, - \Smile\StoreLocator\Model\Retailer\ScheduleManagement $scheduleManagement, - CarrierFactoryInterface $carrierFactory, - \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Framework\App\CacheInterface $cacheInterface + MapProviderInterface $mapProvider, + private CollectionFactory $retailerCollectionFactory, + private Data $storeLocatorHelper, + private AddressFormatter $addressFormatter, + private Schedule $scheduleHelper, + private ScheduleManagement $scheduleManagement, + private CarrierFactoryInterface $carrierFactory, + private UrlInterface $urlBuilder, + private CacheInterface $cache ) { - $this->map = $mapProvider->getMap(); - $this->retailerCollectionFactory = $retailerCollectionFactory; - $this->storeLocatorHelper = $storeLocatorHelper; - $this->addressFormatter = $addressFormatter; - $this->scheduleHelper = $scheduleHelper; - $this->scheduleManager = $scheduleManagement; - $this->carrierFactory = $carrierFactory; - $this->urlBuilder = $urlBuilder; - $this->cache = $cacheInterface; + $this->map = $mapProvider->getMap(); } /** - * {@inheritdoc} + * @inheritdoc */ public function process($jsLayout) { @@ -128,8 +59,8 @@ public function process($jsLayout) // @codingStandardsIgnoreEnd $storeDelivery['provider'] = $this->map->getIdentifier(); - $storeDelivery['markers'] = $this->getStores(); - $storeDelivery = array_merge($storeDelivery, $this->map->getConfig()); + $storeDelivery['markers'] = $this->getStores(); + $storeDelivery = array_merge($storeDelivery, $this->map->getConfig()); // @codingStandardsIgnoreStart $jsLayout['components']['checkout']['children']['steps']['children'] @@ -146,7 +77,7 @@ public function process($jsLayout) // @codingStandardsIgnoreEnd $geocoder['provider'] = $this->map->getIdentifier(); - $geocoder = array_merge($geocoder, $this->map->getConfig()); + $geocoder = array_merge($geocoder, $this->map->getConfig()); // @codingStandardsIgnoreStart $jsLayout['components']['checkout']['children']['steps']['children'] @@ -161,10 +92,8 @@ public function process($jsLayout) /** * List of markers displayed on the map. - * - * @return array */ - private function getStores() + private function getStores(): array { $collection = $this->getRetailerCollection(); $cacheKey = sprintf("%s_%s", 'checkout_storedelivery', $collection->getStoreId()); @@ -174,26 +103,30 @@ private function getStores() $markers = []; /** @var RetailerInterface $retailer */ foreach ($collection as $retailer) { - $address = $retailer->getExtensionAttributes()->getAddress(); - $coords = $address->getCoordinates(); + /** @var RetailerExtensionInterface $retailerExtensionAttr */ + $retailerExtensionAttr = $retailer->getExtensionAttributes(); + /** @var DataObject|RetailerAddressInterface $address */ + $address = $retailerExtensionAttr->getAddress(); + $coords = $address->getCoordinates(); $markerData = [ - 'id' => $retailer->getId(), - 'latitude' => $coords->getLatitude(), - 'longitude' => $coords->getLongitude(), - 'name' => $retailer->getName(), - 'address' => $this->addressFormatter->formatAddress($address, AddressFormatter::FORMAT_ONELINE), - 'url' => $this->storeLocatorHelper->getRetailerUrl($retailer), + 'id' => $retailer->getId(), + 'latitude' => $coords->getLatitude(), + 'longitude' => $coords->getLongitude(), + 'name' => $retailer->getName(), + 'address' => $this->addressFormatter->formatAddress($address, AddressFormatter::FORMAT_ONELINE), + 'url' => $this->storeLocatorHelper->getRetailerUrl($retailer), 'directionUrl' => $this->map->getDirectionUrl($address->getCoordinates()), 'setStoreData' => $this->getSetStorePostData($retailer), - 'addressData' => $address->getData(), + 'addressData' => $address->getData(), ]; + // phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge $markerData['schedule'] = array_merge( $this->scheduleHelper->getConfig(), [ - 'calendar' => $this->scheduleManager->getCalendar($retailer), - 'openingHours' => $this->scheduleManager->getWeekOpeningHours($retailer), - 'specialOpeningHours' => $retailer->getExtensionAttributes()->getSpecialOpeningHours(), + 'calendar' => $this->scheduleManagement->getCalendar($retailer), + 'openingHours' => $this->scheduleManagement->getWeekOpeningHours($retailer), + 'specialOpeningHours' => $retailerExtensionAttr->getSpecialOpeningHours(), ] ); @@ -213,10 +146,8 @@ private function getStores() /** * Collection of displayed retailers. - * - * @return \Smile\Retailer\Model\ResourceModel\Retailer\Collection */ - private function getRetailerCollection() + private function getRetailerCollection(): Collection { $retailerCollection = $this->retailerCollectionFactory->create(); $retailerCollection->addAttributeToSelect( @@ -231,12 +162,8 @@ private function getRetailerCollection() /** * Get the JSON post data used to build the set store link. - * - * @param \Smile\Retailer\Api\Data\RetailerInterface $retailer The store - * - * @return string */ - private function getSetStorePostData($retailer) + private function getSetStorePostData(RetailerInterface $retailer): array { $setUrl = $this->urlBuilder->getUrl('storelocator/store/set'); $postData = ['id' => $retailer->getId()]; diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b4d4493 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [2.0.0] - 2023-09-20 +[2.0.0]: https://github.com/Smile-SA/magento2-module-store-delivery/compare/1.1.10...2.0.0 + +Dataset compatibility ES 2.11.x and PHP 8.2 + +- Fix Dynamic type declaration +- Fix Type hinting +- Replace `Zend_Date` by `DateTime` +- Remove `MutationObserver` support +- Fix UI Component Retailer Offer editing +- Replace `Zend_Validate` by `Laminas\Validator` +- Fix Retailer Grid Column Action +- Fix Retailer Grid Mass Actions +- Fix some translations +- Remove Temando/Shipping Plugin diff --git a/Model/Carrier.php b/Model/Carrier.php index 558044d..231b37a 100644 --- a/Model/Carrier.php +++ b/Model/Carrier.php @@ -1,89 +1,46 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + +declare(strict_types=1); + namespace Smile\StoreDelivery\Model; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\DataObject; +use Magento\Quote\Model\Quote\Address\RateRequest; +use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory; +use Magento\Quote\Model\Quote\Address\RateResult\Method; +use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory; use Magento\Shipping\Model\Carrier\AbstractCarrier; use Magento\Shipping\Model\Carrier\CarrierInterface; +use Magento\Shipping\Model\Rate\Result; use Magento\Shipping\Model\Rate\ResultFactory; -use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory; -use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory; -use Magento\Quote\Model\Quote\Address\RateRequest; use Psr\Log\LoggerInterface; /** - * Store Delivery Carrier model - * @SuppressWarnings(PHPMD.CamelCasePropertyName) - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud + * Store Delivery Carrier model. */ class Carrier extends AbstractCarrier implements CarrierInterface { - /** - * Constant for method code - */ - const METHOD_CODE = 'smilestoredelivery'; + public const METHOD_CODE = 'smilestoredelivery'; - /** - * @var string - */ + // phpcs:disable SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint protected $_code = self::METHOD_CODE; - - /** - * Whether this carrier has fixed rates calculation - * - * @var boolean - */ protected $_isFixed = true; + // phpcs:enable - /** - * @var ResultFactory - */ - protected $rateResultFactory; - - /** - * @var MethodFactory - */ - protected $rateMethodFactory; - - /** - * Carrier constructor - * - * @param ScopeConfigInterface $scopeConfig Scope Configuration - * @param ErrorFactory $rateErrorFactory Rate error Factory - * @param LoggerInterface $logger Logger - * @param ResultFactory $rateResultFactory Rate result Factory - * @param MethodFactory $rateMethodFactory Rate method Factory - * @param array $data Carrier Data - */ public function __construct( ScopeConfigInterface $scopeConfig, ErrorFactory $rateErrorFactory, LoggerInterface $logger, - ResultFactory $rateResultFactory, - MethodFactory $rateMethodFactory, + protected ResultFactory $rateResultFactory, + protected MethodFactory $rateMethodFactory, array $data = [] ) { - $this->rateResultFactory = $rateResultFactory; - $this->rateMethodFactory = $rateMethodFactory; parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data); } /** - * {@inheritdoc} + * @inheritdoc */ public function getAllowedMethods() { @@ -91,7 +48,7 @@ public function getAllowedMethods() } /** - * {@inheritdoc} + * @inheritdoc */ public function collectRates(RateRequest $request) { @@ -99,10 +56,10 @@ public function collectRates(RateRequest $request) return false; } - /** @var \Magento\Shipping\Model\Rate\Result $result */ + /** @var Result|DataObject $result */ $result = $this->rateResultFactory->create(); - /** @var \Magento\Quote\Model\Quote\Address\RateResult\Method $method */ + /** @var Method $method */ $method = $this->rateMethodFactory->create(); $method->setCarrier($this->getCarrierCode()); @@ -111,7 +68,7 @@ public function collectRates(RateRequest $request) $method->setMethod($this->getCarrierCode()); $method->setMethodTitle($this->getConfigData('name')); - $amount = $this->getConfigData('price'); + $amount = (float) $this->getConfigData('price'); $price = $this->getFinalPriceWithHandlingFee($amount); diff --git a/Observer/QuoteSubmit.php b/Observer/QuoteSubmit.php index c1ee44b..a6319fa 100644 --- a/Observer/QuoteSubmit.php +++ b/Observer/QuoteSubmit.php @@ -1,65 +1,47 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + +declare(strict_types=1); + namespace Smile\StoreDelivery\Observer; +use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; +use Magento\Quote\Api\Data\AddressInterface; +use Magento\Quote\Api\Data\CartInterface; +use Magento\Quote\Model\Quote; use Magento\Shipping\Model\CarrierFactoryInterface; +use Smile\StoreDelivery\Model\Carrier; /** * Observer to ensure Billing Address has required fields when using StoreDelivery shipping Method. - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud */ class QuoteSubmit implements ObserverInterface { - /** - * @var \Magento\Shipping\Model\CarrierFactoryInterface - */ - private $carrierFactory; - - /** - * QuoteSubmit constructor. - * - * @param \Magento\Shipping\Model\CarrierFactoryInterface $carrierFactory Carrier Factory - */ - public function __construct(CarrierFactoryInterface $carrierFactory) + public function __construct(private CarrierFactoryInterface $carrierFactory) { - $this->carrierFactory = $carrierFactory; } /** - * Set mandatory fields to shipping address from the billing one, if needed. - * - * This can occur when using Store Delivery, since the Shipping Address is set before the Billing. - * In this case, the shipping address may not have the proper value for FirstName, LastName, and Telephone. - * - * @event checkout_submit_before - * - * @param \Magento\Framework\Event\Observer $observer The observer + * @inheritdoc */ - public function execute(\Magento\Framework\Event\Observer $observer) + public function execute(Observer $observer) { - /** @var \Magento\Quote\Api\Data\CartInterface $quote */ + // Set mandatory fields to shipping address from the billing one, if needed. + // This can occur when using Store Delivery, since the Shipping Address is set before the Billing. + // In this case, the shipping address may not have the proper value for FirstName, LastName, and Telephone. + + /** @var CartInterface|Quote $quote */ $quote = $observer->getQuote(); - /** @var \Magento\Quote\Api\Data\AddressInterface $shippingAddress */ + /** @var AddressInterface $shippingAddress */ + // @phpstan-ignore-next-line : correct reference to interface $shippingAddress = $quote->getShippingAddress(); + // @phpstan-ignore-next-line if ($shippingAddress) { + // @phpstan-ignore-next-line : correct reference to interface $shippingMethod = $shippingAddress->getShippingMethod(); if ($shippingMethod) { - $methodCode = \Smile\StoreDelivery\Model\Carrier::METHOD_CODE; + $methodCode = Carrier::METHOD_CODE; $carrier = $this->carrierFactory->getIfActive($methodCode); if ($carrier && $shippingMethod === sprintf('%s_%s', $methodCode, $carrier->getCarrierCode())) { $billingAddress = $quote->getBillingAddress(); diff --git a/Plugin/Checkout/Api/SaveAddressPlugin.php b/Plugin/Checkout/Api/SaveAddressPlugin.php index 76ae949..515f980 100644 --- a/Plugin/Checkout/Api/SaveAddressPlugin.php +++ b/Plugin/Checkout/Api/SaveAddressPlugin.php @@ -1,85 +1,58 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + +declare(strict_types=1); + namespace Smile\StoreDelivery\Plugin\Checkout\Api; +use Magento\Checkout\Api\Data\ShippingInformationInterface; +use Magento\Checkout\Api\ShippingInformationManagementInterface; +use Magento\Customer\Api\Data\AddressInterfaceFactory; +use Magento\Quote\Model\Quote\Address; +use Smile\Retailer\Api\Data\RetailerInterface; use Smile\Retailer\Api\RetailerRepositoryInterface; /** - * Plugin to save a Store address as Shipping Address - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud + * Plugin to save a Store address as Shipping Address. */ class SaveAddressPlugin { - /** - * @var \Magento\Customer\Model\Session - */ - private $customerSession; - - /** - * @var \Smile\Retailer\Api\RetailerRepositoryInterface - */ - private $retailerRepository; + private AddressInterfaceFactory $addressDataFactory; - /** - * @var \Magento\Customer\Api\Data\AddressInterfaceFactory - */ - private $addressDataFactory; - - /** - * @param RetailerRepositoryInterface $retailerRepository Retailer Repository - * @param \Magento\Customer\Model\Session $customerSession Customer session - * @param \Magento\Customer\Api\Data\AddressInterfaceFactory $addressInterfaceFactory Address Factory - */ public function __construct( - RetailerRepositoryInterface $retailerRepository, - \Magento\Customer\Model\Session $customerSession, - \Magento\Customer\Api\Data\AddressInterfaceFactory $addressInterfaceFactory + private RetailerRepositoryInterface $retailerRepository, + AddressInterfaceFactory $addressInterfaceFactory ) { - $this->retailerRepository = $retailerRepository; - $this->customerSession = $customerSession; $this->addressDataFactory = $addressInterfaceFactory; } /** - * Convert Store Address to Shipping Address - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @param \Magento\Checkout\Api\ShippingInformationManagementInterface $subject Shipping Information Management - * @param int $cartId Cart Id - * @param \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation Address Information + * Convert Store Address to Shipping Address. * - * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeSaveAddressInformation( - \Magento\Checkout\Api\ShippingInformationManagementInterface $subject, - $cartId, - \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation - ) { + ShippingInformationManagementInterface $subject, + mixed $cartId, + ShippingInformationInterface $addressInformation + ): void { + /** @var Address $shippingAddress */ $shippingAddress = $addressInformation->getShippingAddress(); $billingAddress = $addressInformation->getBillingAddress(); + // @phpstan-ignore-next-line if ($shippingAddress->getExtensionAttributes() && $shippingAddress->getExtensionAttributes()->getRetailerId()) { - $retailer = $this->retailerRepository->get($shippingAddress->getExtensionAttributes()->getRetailerId()); + /** @var RetailerInterface $retailer */ + $retailer = $this->retailerRepository->get( + // @phpstan-ignore-next-line + (int) $shippingAddress->getExtensionAttributes()->getRetailerId() + ); if ($retailer->getId()) { $address = $this->addressDataFactory->create( - ['data' => $retailer->getAddress()->getData()] + ['data' => $retailer->getData('address')->getData()] ); $shippingAddress->importCustomerAddressData($address); $shippingAddress->setCompany($retailer->getName()); - $shippingAddress->setRetailerId((int) $retailer->getId()); + $shippingAddress->setData('retailer_id', (string) $retailer->getId()); // Potentially copy billing fields (if present, this is not the case when customer is not logged in). if (!$shippingAddress->getFirstname()) { diff --git a/Plugin/Quote/Api/ShipmentEstimationPlugin.php b/Plugin/Quote/Api/ShipmentEstimationPlugin.php index f0fd712..74ff7a0 100644 --- a/Plugin/Quote/Api/ShipmentEstimationPlugin.php +++ b/Plugin/Quote/Api/ShipmentEstimationPlugin.php @@ -1,55 +1,45 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + +declare(strict_types=1); + namespace Smile\StoreDelivery\Plugin\Quote\Api; +use Closure; +use Magento\Quote\Api\Data\AddressInterface; +use Magento\Quote\Api\Data\ShippingMethodInterface; use Magento\Quote\Api\ShipmentEstimationInterface; +use Smile\StoreDelivery\Model\Carrier; /** - * Shipment Estimation Plugin. - * Allow only Store Delivery - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud + * Shipment Estimation Plugin. Allows only Store Delivery. */ class ShipmentEstimationPlugin { /** * Ensure StoreDelivery is the only available shipping method for store delivery addresses. - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @param \Magento\Quote\Api\ShipmentEstimationInterface $subject Shipment Estimation Interface - * @param \Closure $proceed The estimateByExtendedAddress method - * @param mixed $cartId The cart Id - * @param \Magento\Quote\Api\Data\AddressInterface $address The Shipping Address * - * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundEstimateByExtendedAddress( ShipmentEstimationInterface $subject, - \Closure $proceed, - $cartId, - \Magento\Quote\Api\Data\AddressInterface $address - ) { + Closure $proceed, + mixed $cartId, + AddressInterface $address + ): mixed { $shippingMethods = $proceed($cartId, $address); // If shipping address is linked to a retailer, remove all methods except Store Delivery. - /** @var \Magento\Quote\Api\Data\ShippingMethodInterface $shippingMethod */ + /** @var ShippingMethodInterface $shippingMethod */ foreach ($shippingMethods as $key => $shippingMethod) { - if (($address->getExtensionAttributes() && $address->getExtensionAttributes()->getRetailerId() - && ($shippingMethod->getMethodCode() !== \Smile\StoreDelivery\Model\Carrier::METHOD_CODE)) || - ((!$address->getExtensionAttributes() || (null === $address->getExtensionAttributes()->getRetailerId())) - && ($shippingMethod->getMethodCode() === \Smile\StoreDelivery\Model\Carrier::METHOD_CODE)) + if ( + ($address->getExtensionAttributes() + // @phpstan-ignore-next-line + && $address->getExtensionAttributes()->getRetailerId() + && ($shippingMethod->getMethodCode() !== Carrier::METHOD_CODE)) + || ((!$address->getExtensionAttributes() + // @phpstan-ignore-next-line + || (null === $address->getExtensionAttributes()->getRetailerId())) + && ($shippingMethod->getMethodCode() === Carrier::METHOD_CODE)) ) { unset($shippingMethods[$key]); } diff --git a/Plugin/Quote/Api/ShippingMethodManagementPlugin.php b/Plugin/Quote/Api/ShippingMethodManagementPlugin.php index a2ed4f2..e1370a6 100644 --- a/Plugin/Quote/Api/ShippingMethodManagementPlugin.php +++ b/Plugin/Quote/Api/ShippingMethodManagementPlugin.php @@ -1,49 +1,33 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + +declare(strict_types=1); + namespace Smile\StoreDelivery\Plugin\Quote\Api; +use Closure; +use Magento\Quote\Api\Data\ShippingMethodInterface; use Magento\Quote\Api\ShippingMethodManagementInterface; use Smile\StoreDelivery\Model\Carrier; /** * Plugin to remove Store Delivery from available carriers for estimation by addressId. - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud */ class ShippingMethodManagementPlugin { /** * Remove StoreDelivery from available methods when estimating by address Id (existing customer addresses). - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @param \Magento\Quote\Api\ShippingMethodManagementInterface $subject Shipping Method Management - * @param \Closure $proceed estimateByAddressId() method - * @param int $cartId The shopping cart ID. - * @param int $addressId The estimate address id * - * @return mixed + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundEstimateByAddressId( ShippingMethodManagementInterface $subject, - \Closure $proceed, - $cartId, - $addressId - ) { + Closure $proceed, + mixed $cartId, + mixed $addressId + ): mixed { $shippingMethods = $proceed($cartId, $addressId); - /** @var \Magento\Quote\Api\Data\ShippingMethodInterface $shippingMethod */ + /** @var ShippingMethodInterface $shippingMethod */ foreach ($shippingMethods as $key => $shippingMethod) { if ($shippingMethod->getMethodCode() === Carrier::METHOD_CODE) { unset($shippingMethods[$key]); diff --git a/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php b/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php index b5924bb..893db53 100644 --- a/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php +++ b/Plugin/Quote/Model/ConvertQuoteAddressToOrderAddress.php @@ -1,44 +1,34 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ + +declare(strict_types=1); + namespace Smile\StoreDelivery\Plugin\Quote\Model; +use Closure; +use Magento\Quote\Model\Quote\Address; +use Magento\Quote\Model\Quote\Address\ToOrderAddress; +use Magento\Sales\Api\Data\OrderAddressInterface; + /** * Plugin to copy "retailer_id" field from quote_address to order_address. * Done via a plugin because fieldset.xml does not seem to work. - * see https://magento.stackexchange.com/questions/124712/magento-2-fieldset-xml-copy-fields-from-quote-to-order - * see https://github.com/magento/magento2/issues/5823 * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud + * @see https://magento.stackexchange.com/questions/124712/magento-2-fieldset-xml-copy-fields-from-quote-to-order + * @see https://github.com/magento/magento2/issues/5823 */ class ConvertQuoteAddressToOrderAddress { /** - * @param \Magento\Quote\Model\Quote\Address\ToOrderAddress $subject The converter - * @param \Closure $proceed Converter convert() method - * @param \Magento\Quote\Model\Quote\Address $quoteAddress Quote Address - * @param array $data Data + * Copy retailer_id field from quote_address to order_address. * - * @return \Magento\Sales\Api\Data\OrderAddressInterface Order Address * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundConvert( - \Magento\Quote\Model\Quote\Address\ToOrderAddress $subject, - \Closure $proceed, - \Magento\Quote\Model\Quote\Address $quoteAddress, - $data = [] - ) { + ToOrderAddress $subject, + Closure $proceed, + Address $quoteAddress, + array $data = [] + ): OrderAddressInterface { $orderAddress = $proceed($quoteAddress, $data); if ($quoteAddress->getRetailerId()) { $orderAddress->setRetailerId($quoteAddress->getRetailerId()); diff --git a/Plugin/Temando/SaveCheckoutFieldsObserverPlugin.php b/Plugin/Temando/SaveCheckoutFieldsObserverPlugin.php deleted file mode 100644 index 2ec4f29..0000000 --- a/Plugin/Temando/SaveCheckoutFieldsObserverPlugin.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright 2018 Smile - * @license Open Software License ("OSL") v. 3.0 - */ -namespace Smile\StoreDelivery\Plugin\Temando; - -/** - * This observer is here to prevent erratic behavior of Temando module. @see https://github.com/magento/magento2/issues/12921 - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - */ -class SaveCheckoutFieldsObserverPlugin -{ - /** - * Better check than what is done in the Temando Observer which is thinking he is the only one adding extension - * attributes to the Quote address. - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @param \Temando\Shipping\Observer\SaveCheckoutFieldsObserver $subject Base Temando Observer - * @param \Closure $proceed execute() method of Temando Observer - * @param \Magento\Framework\Event\Observer $observer Magento Event Observer - */ - public function aroundExecute( - \Temando\Shipping\Observer\SaveCheckoutFieldsObserver $subject, - \Closure $proceed, - \Magento\Framework\Event\Observer $observer - ) { - /** @var \Magento\Quote\Api\Data\AddressInterface|\Magento\Quote\Model\Quote\Address $quoteAddress */ - $quoteAddress = $observer->getData('quote_address'); - if ($quoteAddress->getAddressType() !== \Magento\Quote\Model\Quote\Address::ADDRESS_TYPE_SHIPPING) { - return; - } - - if (!$quoteAddress->getExtensionAttributes()) { - return; - } - - if (!$quoteAddress->getExtensionAttributes()->getCheckoutFields()) { - return; - } - - $proceed($observer); - } -} diff --git a/README.md b/README.md index ca52de4..f8f0271 100644 --- a/README.md +++ b/README.md @@ -6,21 +6,21 @@ This module add the ability to be delivered in store. Store delivery is a shippi ### Requirements -The module requires : +The module requires: -- [Store Locator](https://github.com/Smile-SA/magento2-module-store-locator) > 1.2.* +- [Store Locator](https://github.com/Smile-SA/magento2-module-store-locator) >= 2.2.* ### How to use -1. Install the module via Composer : +1. Install the module via Composer: ``` composer require smile/module-store-delivery ``` -2. Enable it +2. Enable it: ``` bin/magento module:enable Smile_StoreDelivery ``` -3. Install the module and rebuild the DI cache +3. Install the module and rebuild the DI cache: ``` bin/magento setup:upgrade ``` diff --git a/Setup/InstallData.php b/Setup/InstallData.php deleted file mode 100644 index 28f5dd9..0000000 --- a/Setup/InstallData.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ -namespace Smile\StoreDelivery\Setup; - -use Magento\Framework\Setup\InstallDataInterface; -use Magento\Framework\Setup\ModuleContextInterface; -use Magento\Framework\Setup\ModuleDataSetupInterface; -use Magento\Quote\Setup\QuoteSetupFactory; -use Magento\Sales\Setup\SalesSetupFactory; -use Magento\Eav\Setup\EavSetup; -use Magento\Eav\Setup\EavSetupFactory; -use Smile\Retailer\Api\Data\RetailerInterface; -use Smile\Seller\Api\Data\SellerInterface; - -/** - * Smile StoreDelivery Install Data. - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - */ -class InstallData implements InstallDataInterface -{ - /** - * @var \Magento\Sales\Setup\SalesSetupFactory - */ - private $salesSetupFactory; - - /** - * @var \Magento\Quote\Setup\QuoteSetupFactory - */ - private $quoteSetupFactory; - - /** - * @var \Magento\Eav\Setup\EavSetupFactory - */ - private $eavSetupFactory; - - /** - * InstallData constructor. - * - * @param \Magento\Sales\Setup\SalesSetupFactory $salesSetupFactory Sales Setup - * @param \Magento\Quote\Setup\QuoteSetupFactory $quoteSetupFactory Quote Setup - * @param \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory EAV Setup Factory. - */ - public function __construct( - SalesSetupFactory $salesSetupFactory, - QuoteSetupFactory $quoteSetupFactory, - EavSetupFactory $eavSetupFactory - ) { - $this->salesSetupFactory = $salesSetupFactory; - $this->quoteSetupFactory = $quoteSetupFactory; - $this->eavSetupFactory = $eavSetupFactory; - } - - - /** - * {@inheritdoc} - */ - public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) - { - $setup->startSetup(); - - $this->addSalesAttributes($setup); - - /** @var EavSetup $eavSetup */ - $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); - $this->addShopAttributes($eavSetup); - - $setup->endSetup(); - } - - /** - * Add retailer_id attribute to sales_order_address and sales_quote_address - * - * @param ModuleDataSetupInterface $setup Data Setup - */ - private function addSalesAttributes($setup) - { - /** @var \Magento\Sales\Setup\SalesSetup $salesSetup */ - $salesSetup = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]); - - /** @var \Magento\Quote\Setup\QuoteSetup $quoteSetup */ - $quoteSetup = $this->quoteSetupFactory->create(['resourceName' => 'quote_setup', 'setup' => $setup]); - - $quoteSetup->addAttribute( - 'quote_address', - 'retailer_id', - ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 'visible' => false] - ); - - $salesSetup->addAttribute( - 'order_address', - 'retailer_id', - ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 'visible' => false] - ); - } - - /** - * Add allow_store_delivery attribute to Retailer - * - * @param \Magento\Eav\Setup\EavSetup $eavSetup EAV module Setup - */ - private function addShopAttributes($eavSetup) - { - $entityId = SellerInterface::ENTITY; - $attrSetId = RetailerInterface::ATTRIBUTE_SET_RETAILER; - $groupId = 'Shipping'; - - $eavSetup->addAttributeGroup($entityId, $attrSetId, $groupId, 200); - - $eavSetup->addAttribute( - SellerInterface::ENTITY, - 'allow_store_delivery', - [ - 'type' => 'int', - 'label' => 'Allow Store Delivery', - 'input' => 'boolean', - 'required' => true, - 'user_defined' => true, - 'sort_order' => 10, - 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, - 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', - ] - ); - - $eavSetup->addAttributeToGroup($entityId, $attrSetId, $groupId, 'allow_store_delivery', 10); - } -} diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php deleted file mode 100644 index b8efce4..0000000 --- a/Setup/InstallSchema.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ -namespace Smile\StoreDelivery\Setup; - -use Magento\Framework\Setup\InstallSchemaInterface; -use Magento\Framework\Setup\ModuleContextInterface; -use Magento\Framework\Setup\SchemaSetupInterface; - -/** - * Smile StoreDelivery Install Schema. - * Mandatory for Magento <2.2 to backport a fix on shipping_method field. - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - */ -class InstallSchema implements InstallSchemaInterface -{ - /** - * @var \Magento\Framework\App\ProductMetadataInterface - */ - private $metadata; - - /** - * InstallSchema constructor. - * - * @param \Magento\Framework\App\ProductMetadataInterface $metadata Magento metadata - */ - public function __construct(\Magento\Framework\App\ProductMetadataInterface $metadata) - { - $this->metadata = $metadata; - } - - /** - * {@inheritdoc} - */ - public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) - { - $setup->startSetup(); - - if (version_compare($this->metadata->getVersion(), '2.2.0', '<')) { - $connection = $setup->getConnection(); - - // Set the "shipping_method" column of quote_address and sales_order tables to 120 chars length. - // This is a fix for a Magento's internal issue. - // @see https://github.com/magento/magento2/issues/6475 - // This has been fixed in Magento 2.2 only, that's why it's backported here for now. - // This setup will have no effect on a Magento > 2.2 and is only needed for < 2.2 instances. - $connection->modifyColumn( - $setup->getTable('quote_address'), - 'shipping_method', - [ - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'length' => 120, - ] - ); - - $connection->modifyColumn( - $setup->getTable('sales_order'), - 'shipping_method', - [ - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'length' => 120, - ] - ); - } - - $setup->endSetup(); - } -} diff --git a/Setup/Patch/Data/AddStoreDeliveryAttributes.php b/Setup/Patch/Data/AddStoreDeliveryAttributes.php new file mode 100644 index 0000000..621e2a2 --- /dev/null +++ b/Setup/Patch/Data/AddStoreDeliveryAttributes.php @@ -0,0 +1,103 @@ +moduleDataSetup->startSetup(); + + /** @var EavSetup $eavSetup */ + $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]); + $this->addShopAttributes($eavSetup); + + $this->moduleDataSetup->endSetup(); + + return $this; + } + + /** + * Add allow_store_delivery attribute to Retailer. + */ + private function addShopAttributes(EavSetup $eavSetup): void + { + $entityId = SellerInterface::ENTITY; + $attrSetId = RetailerInterface::ATTRIBUTE_SET_RETAILER; + $groupId = 'Shipping'; + + $eavSetup->addAttributeGroup($entityId, $attrSetId, $groupId, 200); + + $eavSetup->addAttribute( + SellerInterface::ENTITY_TYPE_CODE, + 'allow_store_delivery', + [ + 'type' => 'int', + 'label' => 'Allow Store Delivery', + 'input' => 'boolean', + 'required' => true, + 'user_defined' => true, + 'sort_order' => 10, + 'global' => ScopedAttributeInterface::SCOPE_GLOBAL, + 'source' => Boolean::class, + ] + ); + + $eavSetup->addAttributeToGroup($entityId, $attrSetId, $groupId, 'allow_store_delivery', 10); + } + + /** + * @inheritdoc + */ + public static function getDependencies(): array + { + return []; + } + + /** + * @inheritdoc + */ + public static function getVersion(): string + { + return '2.0.1'; + } + + /** + * @inheritdoc + */ + public function getAliases(): array + { + return []; + } +} diff --git a/composer.json b/composer.json index d09e500..7ac9b09 100644 --- a/composer.json +++ b/composer.json @@ -3,36 +3,44 @@ "type": "magento2-module", "description": "Smile Store Delivery", "keywords": ["magento2", "store delivery", "click in store", "delivery in store"], - "repositories": [ + "license": "OSL-3.0", + "authors": [ { - "type": "composer", - "url": "https://repo.magento.com/" + "name": "Romain Ruaud", + "email": "romain.ruaud@smile.fr" } ], "require": { - "magento/framework": "*", - "magento/module-store": "*", - "magento/module-checkout": "*", - "smile/module-store-locator": "~1.3.0 || ~2.0.0" + "php": "^8.1", + "magento/framework": ">=103.0.4", + "magento/module-checkout": ">=100.4.4", + "magento/module-store": ">=101.1.4", + "smile/module-store-locator": "^2.2" }, "require-dev": { - "smile/magento2-smilelab-quality-suite": "^1.0.5" + "smile/magento2-smilelab-quality-suite": "^3.0" }, - "license": "OSL-3.0", - "authors": [ + "repositories": [ { - "name": "Romain Ruaud", - "email": "romain.ruaud@smile.fr" + "type": "composer", + "url": "https://repo.magento.com/" } ], + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "files": [ "registration.php" ], "psr-4": { - "Smile\\StoreDelivery\\" : "" + "Smile\\StoreDelivery\\": "" } }, - "minimum-stability": "dev", - "prefer-stable": true + "config": { + "allow-plugins": { + "magento/composer-dependency-version-audit-plugin": true, + "dealerdirect/phpcodesniffer-composer-installer": true + }, + "sort-packages": true + } } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index d3d25f9..1fee851 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -1,18 +1,4 @@ -
diff --git a/etc/config.xml b/etc/config.xml index 8cd2e5d..57739b1 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,18 +1,4 @@ - @@ -31,4 +17,3 @@ - diff --git a/etc/db_schema.xml b/etc/db_schema.xml new file mode 100644 index 0000000..570e228 --- /dev/null +++ b/etc/db_schema.xml @@ -0,0 +1,13 @@ + + + + + +
+ + +
+
diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json new file mode 100644 index 0000000..48cca0f --- /dev/null +++ b/etc/db_schema_whitelist.json @@ -0,0 +1,12 @@ +{ + "sales_order_address": { + "column": { + "retailer_id": true + } + }, + "quote_address": { + "column": { + "retailer_id": true + } + } +} \ No newline at end of file diff --git a/etc/di.xml b/etc/di.xml index e017e15..a7e1dab 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,20 +1,4 @@ - @@ -33,8 +17,5 @@ - - - - + diff --git a/etc/events.xml b/etc/events.xml index 85668b1..14a04f6 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -1,20 +1,6 @@ - - + diff --git a/etc/extension_attributes.xml b/etc/extension_attributes.xml index e8dd2b6..326fbc4 100644 --- a/etc/extension_attributes.xml +++ b/etc/extension_attributes.xml @@ -1,20 +1,6 @@ - - + diff --git a/etc/fieldset.xml b/etc/fieldset.xml index af45c6e..5e71fb0 100644 --- a/etc/fieldset.xml +++ b/etc/fieldset.xml @@ -1,34 +1,20 @@ -
- +
- +
- +
diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index d130f60..4dded44 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -1,18 +1,4 @@ - diff --git a/etc/module.xml b/etc/module.xml index 50d9504..8ff6c3b 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,20 +1,6 @@ - - + diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..dca2bb5 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + . + vendor/* + diff --git a/phpmd.xml.dist b/phpmd.xml.dist new file mode 100644 index 0000000..8eadf89 --- /dev/null +++ b/phpmd.xml.dist @@ -0,0 +1,10 @@ + + + + + + vendor/* + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..4e40864 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,11 @@ +parameters: + level: 6 + phpVersion: 80100 + checkMissingIterableValueType: false + paths: + - . + excludePaths: + - 'vendor/*' + +includes: + - %currentWorkingDirectory%/vendor/smile/magento2-smilelab-phpstan/extension.neon diff --git a/registration.php b/registration.php index b8fa37c..43538dc 100644 --- a/registration.php +++ b/registration.php @@ -1,19 +1,11 @@ - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, +declare(strict_types=1); + +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register( + ComponentRegistrar::MODULE, 'Smile_StoreDelivery', __DIR__ ); diff --git a/view/adminhtml/ui_component/smile_retailer_listing.xml b/view/adminhtml/ui_component/smile_retailer_listing.xml index f825268..bb3297a 100644 --- a/view/adminhtml/ui_component/smile_retailer_listing.xml +++ b/view/adminhtml/ui_component/smile_retailer_listing.xml @@ -1,20 +1,4 @@ - diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js index 4f597dc..2bc3c7e 100644 --- a/view/frontend/requirejs-config.js +++ b/view/frontend/requirejs-config.js @@ -1,17 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Smile Elastic Suite to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - var config = { map: { '*': { diff --git a/view/frontend/web/css/source/_module.less b/view/frontend/web/css/source/_module.less index 700bdec..96d6d15 100644 --- a/view/frontend/web/css/source/_module.less +++ b/view/frontend/web/css/source/_module.less @@ -1,18 +1,3 @@ -// /** -// * DISCLAIMER -// * -// * Do not edit or add to this file if you wish to upgrade this module to newer -// * versions in the future. -// * -// * -// * @category Smile -// * @package Smile\StoreDelivery -// * @author Romain Ruaud -// * @copyright 2017 Smile -// * @license Open Software License ("OSL") v. 3.0 -// */ - - // // Store Delivery - Checkout Onepage // _____________________________________________ @@ -357,4 +342,3 @@ body.checkout-index-index { } } } - diff --git a/view/frontend/web/js/model/empty-address.js b/view/frontend/web/js/model/empty-address.js index 56e24df..abe34a1 100644 --- a/view/frontend/web/js/model/empty-address.js +++ b/view/frontend/web/js/model/empty-address.js @@ -1,19 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2016 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ define([], function() { /** diff --git a/view/frontend/web/js/model/shipping-rate-processor/store-delivery.js b/view/frontend/web/js/model/shipping-rate-processor/store-delivery.js index 128d0f4..275031b 100644 --- a/view/frontend/web/js/model/shipping-rate-processor/store-delivery.js +++ b/view/frontend/web/js/model/shipping-rate-processor/store-delivery.js @@ -1,4 +1,3 @@ -/*global define*/ define( [ 'Magento_Checkout/js/model/resource-url-manager', diff --git a/view/frontend/web/js/model/shipping-save-processor/store-delivery.js b/view/frontend/web/js/model/shipping-save-processor/store-delivery.js index 0339228..923ded4 100644 --- a/view/frontend/web/js/model/shipping-save-processor/store-delivery.js +++ b/view/frontend/web/js/model/shipping-save-processor/store-delivery.js @@ -1,19 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2016 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ define( [ 'ko', diff --git a/view/frontend/web/js/model/store-address.js b/view/frontend/web/js/model/store-address.js index e41e3c4..65813ef 100644 --- a/view/frontend/web/js/model/store-address.js +++ b/view/frontend/web/js/model/store-address.js @@ -1,19 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2016 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ define([], function() { /** * @param int retailerId diff --git a/view/frontend/web/js/view/checkout/shipping/store-delivery.js b/view/frontend/web/js/view/checkout/shipping/store-delivery.js index 37cfe41..9a72f39 100644 --- a/view/frontend/web/js/view/checkout/shipping/store-delivery.js +++ b/view/frontend/web/js/view/checkout/shipping/store-delivery.js @@ -1,20 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2016 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ - define([ 'uiComponent', 'jquery', @@ -87,11 +70,11 @@ define([ getMethodTitle: function() { return this.methodTitle; }, - + getCarrierCode: function() { return this.carrierCode; }, - + getCarrierTitle: function() { return this.carrierTitle; }, diff --git a/view/frontend/web/js/view/shipping-address/address-renderer/default.js b/view/frontend/web/js/view/shipping-address/address-renderer/default.js index 0a1e7e6..a664f18 100644 --- a/view/frontend/web/js/view/shipping-address/address-renderer/default.js +++ b/view/frontend/web/js/view/shipping-address/address-renderer/default.js @@ -1,20 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2017 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ - define([ 'jquery', 'ko', diff --git a/view/frontend/web/js/view/shipping-address/address-renderer/store-delivery.js b/view/frontend/web/js/view/shipping-address/address-renderer/store-delivery.js index 2573ded..ee4ef4a 100644 --- a/view/frontend/web/js/view/shipping-address/address-renderer/store-delivery.js +++ b/view/frontend/web/js/view/shipping-address/address-renderer/store-delivery.js @@ -1,8 +1,3 @@ -/** - * Copyright © 2013-2017 Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -/*global define*/ define([ 'jquery', 'ko', diff --git a/view/frontend/web/js/view/shipping-address/store-delivery.js b/view/frontend/web/js/view/shipping-address/store-delivery.js index dda0dd2..0b105ea 100644 --- a/view/frontend/web/js/view/shipping-address/store-delivery.js +++ b/view/frontend/web/js/view/shipping-address/store-delivery.js @@ -1,20 +1,3 @@ -/** - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade this module to newer - * versions in the future. - * - * - * @category Smile - * @package Smile\StoreDelivery - * @author Romain Ruaud - * @copyright 2016 Smile - * @license Open Software License ("OSL") v. 3.0 - */ - -/*jshint browser:true jquery:true*/ -/*global alert*/ - define( [ 'uiComponent', diff --git a/view/frontend/web/template/checkout/shipping/store-delivery.html b/view/frontend/web/template/checkout/shipping/store-delivery.html index 86836ab..1b20429 100644 --- a/view/frontend/web/template/checkout/shipping/store-delivery.html +++ b/view/frontend/web/template/checkout/shipping/store-delivery.html @@ -4,7 +4,7 @@ data-bind="attr: { 'value' : getCurrentStore, 'id': 's_method_' + getMethodCode, - }" /> + }"> diff --git a/view/frontend/web/template/checkout/shipping/store-list.html b/view/frontend/web/template/checkout/shipping/store-list.html index e0a89af..0157dd8 100644 --- a/view/frontend/web/template/checkout/shipping/store-list.html +++ b/view/frontend/web/template/checkout/shipping/store-list.html @@ -7,7 +7,7 @@ 'title': $t('Choose this store') }, checked: $parents[1].currentRetailerId - }"/> + }"> diff --git a/view/frontend/web/template/shipping-address/address-renderer/default.html b/view/frontend/web/template/shipping-address/address-renderer/default.html index 58ac774..1d21df0 100644 --- a/view/frontend/web/template/shipping-address/address-renderer/default.html +++ b/view/frontend/web/template/shipping-address/address-renderer/default.html @@ -1,6 +1,6 @@
-
+
@@ -11,18 +11,18 @@ -
-
- ,
-
-
+
+
+ ,
+
+
-
+
-
+
diff --git a/view/frontend/web/template/shipping-address/address-renderer/store-delivery.html b/view/frontend/web/template/shipping-address/address-renderer/store-delivery.html index 0adcdd2..1a030eb 100644 --- a/view/frontend/web/template/shipping-address/address-renderer/store-delivery.html +++ b/view/frontend/web/template/shipping-address/address-renderer/store-delivery.html @@ -7,19 +7,19 @@ -
-
- ,
-
-
+
+
+ ,
+
+
-
+
-
+
diff --git a/view/frontend/web/template/shipping-information/address-renderer/store-delivery.html b/view/frontend/web/template/shipping-information/address-renderer/store-delivery.html index cb2cf79..b5a7a78 100644 --- a/view/frontend/web/template/shipping-information/address-renderer/store-delivery.html +++ b/view/frontend/web/template/shipping-information/address-renderer/store-delivery.html @@ -1,12 +1,12 @@ -
-
-
- ,
-
-
+
+
+
+ ,
+
+